Django includes the django.core.mail.send_mail
method these days (2018), no need to use EmailMultiAlternatives
class directly. Do this instead:
from django.core import mail
from django.template.loader import render_to_string
from django.utils.html import strip_tags
subject = 'Subject'
html_message = render_to_string('mail_template.html', {'context': 'values'})
plain_message = strip_tags(html_message)
from_email = 'From <[email protected]>'
to = '[email protected]'
mail.send_mail(subject, plain_message, from_email, [to], html_message=html_message)
This will send an email which is visible in both html-capable browsers and will show plain text in crippled email viewers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…