Beispiel #1
0
def build_email(subject_template_name,
                email_template_name,
                html_email_template_name,
                context=None,
                reply=False):

    subject = loader.render_to_string(subject_template_name, context)
    subject = settings.EMAIL_SUBJECT_PREFIX + ''.join(subject.splitlines())
    body = loader.render_to_string(email_template_name, context)

    headers = {}
    if reply:
        headers['Reply-To'] = settings.EMAIL_REPLY_TO

    email_message = EmailMultiAlternatives(subject,
                                           body,
                                           settings.EMAIL_FROM,
                                           None,
                                           headers=headers)
    html_email = loader.render_to_string(html_email_template_name, context)
    email_message.attach_alternative(html_email, 'text/html')

    email_message.context = context

    return email_message
Beispiel #2
0
    def mail(self):
        context = self.mail_context()
        subject = _('Qabel Index confirmation')
        body = render_to_string('verification/email.txt', context)
        from_email = settings.DEFAULT_FROM_EMAIL
        email_message = EmailMultiAlternatives(subject, body, from_email, [self.email])
        html_email = render_to_string('verification/email.html', context)
        email_message.attach_alternative(html_email, 'text/html')
        email_message.context = context

        return email_message
Beispiel #3
0
    def mail(self):
        context = self.mail_context()
        subject = _('Qabel Index confirmation')
        body = render_to_string('verification/email.txt', context)
        from_email = settings.DEFAULT_FROM_EMAIL
        email_message = EmailMultiAlternatives(subject, body, from_email,
                                               [self.email])
        html_email = render_to_string('verification/email.html', context)
        email_message.attach_alternative(html_email, 'text/html')
        email_message.context = context

        return email_message