django-mailjet
django-mailjet copied to clipboard
Sending HTML mail as main content does not work
Using MailjetBackend
with the following Django code:
email = EmailMessage(subject, message, from_email, recipients)
email.content_subtype = 'html'
email.send()
... where message
contains some HTML tags is sending to the recipient(s) a plain text mail, where the HTML is not interpreted.
Attaching two alternatives (plain & html) works though, but since the code above is documented as official part of the Django API, I think it should be handled.
EDIT: I should mention this method worked with another competitor backend before :confused:
For information (and those who might be blocked by this), it is possible to workaround this problem by using the following method:
from django.core.mail import EmailMultiAlternatives
mail = EmailMultiAlternatives(
"Subject", "Plain text message", "[email protected]", "[email protected]"
)
mail.attach_alternative("HTML message", 'text/html')
mail.send()
Thus, mail provider seems to prefer displaying the HTML version instead of the plain one.