

def create_email_msg(self, emails, attachments=None, from_email=None, lang=None, message_class=EmailMultiRelated, headers=None):
    'Create an email message instance.'
    from_email = (from_email or settings.DEFAULT_FROM_EMAIL)
    subject = self._render_part('subject.txt', lang=lang).strip()
    try:
        body = self._render_part('body.txt', lang=lang)
    except TemplateDoesNotExist:
        body = None
    try:
        html_content = self._render_part('body.html', lang=lang)
    except TemplateDoesNotExist:
        html_content = None
    if ((html_content is None) and (body is None)):
        raise TemplateDoesNotExist('Txt and html templates have not been found')
    if ((html_content is not None) and (body is None)):
        h = html2text.HTML2Text()
        body = h.handle(html_content)
    if (headers is None):
        reply_to = getattr(settings, 'NO_REPLY_EMAIL', None)
        if (not reply_to):
            reply_to = getattr(settings, 'SUPPORT_EMAIL', settings.DEFAULT_FROM_EMAIL)
        headers = {
            'Reply-To': reply_to,
        }
    msg = message_class(subject, body, from_email, emails, headers=headers)
    if html_content:
        msg.attach_alternative(html_content, 'text/html')
    attachments = self.get_attachments(attachments)
    if attachments:
        for (filepath, filename, mimetype) in attachments:
            with open(filepath, 'rb') as attachment:
                if mimetype.startswith('image'):
                    msg.attach_related_file(filepath, h, filename)
                else:
                    msg.attach(filename, attachment.read(), mimetype)
    return msg

dataset/ETHPy150Open novafloss/django-mail-factory/mail_factory/mails.py BaseMail.create_email_msg/VarMisuse@318/468 `mimetype`->`h`