def _create_msg(self, to, subject, msgHtml, msgPlain, attachments=None):
sender = self.sender<EOL>if attachments and isinstance(attachments, str):<EOL><INDENT>attachments = [attachments]<EOL><DEDENT>else:<EOL><INDENT>attachments = list(attachments or [])<EOL><DEDENT>msg = MIMEMultipart('<STR_LIT>')<EOL>msg['<STR_LIT>'] = subject<EOL>msg['<STR_LIT>'] = sender<EOL>msg['<STR_LIT>'] = to<EOL>msg.attach(MIMEText(msgPlain, '<STR_LIT>'))<EOL>msg.attach(MIMEText(msgHtml, '<STR_LIT:html>'))<EOL>for path in attachments:<EOL><INDENT>_attachment = self._prep_attachment(path)<EOL>msg.attach(_attachment)<EOL><DEDENT>raw = base64.urlsafe_b64encode(msg.as_bytes()).decode()<EOL>body = {'<STR_LIT>': raw}<EOL>return body<EOL>
attachments should be a list of paths