Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending HTML mail as main content does not work #1

Open
mlorant opened this issue May 11, 2016 · 1 comment
Open

Sending HTML mail as main content does not work #1

mlorant opened this issue May 11, 2016 · 1 comment
Assignees
Labels

Comments

@mlorant
Copy link

mlorant commented May 11, 2016

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 😕

@kidig kidig added the bug label May 11, 2016
@kidig kidig self-assigned this May 11, 2016
@mlorant
Copy link
Author

mlorant commented Aug 24, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants