Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20817 closed New feature (fixed)

Add support for html email messages through django.core.mail.send_mail()

Reported by: jmichalicek Owned by: nobody
Component: Core (Mail) Version: master
Severity: Normal Keywords: mail, send_mail
Cc: timograham@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I have run into several instances where it makes sense to be able to send html email messages through django.core.mail.send_mail(). Allowing this would also be consistent with the mail_admins() and mail_managers() functions.

When adding this I did see that the comments for send_mail() say that the api is frozen. I had previously asked about this feature on the django-developers google group in this thread https://groups.google.com/forum/#!topic/django-developers/_mXKP9JZzK0 so I hope this is not a problem.

I have forked the repo and created a feature branch at https://github.com/jmichalicek/django/tree/add_send_mail_html_message which has the feature, updated documentation, and test cases.

Change History (5)

comment:1 Changed 2 years ago by timo

  • Cc timograham@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Given that Russ seemed to accept the ticket in the mailing list and was the one who committed the original change which included the comment about the API being frozen, I assume this is fine.

I left minor doc comments on the PR.

comment:2 Changed 2 years ago by jmichalicek

  • Triage Stage changed from Accepted to Unreviewed

Thanks, I've updated the docs as noted in the comments.

comment:3 Changed 2 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In ac0955876089002f0f60857d09fe1c94d67eca4f:

Fixed #20817 -- Added html_message parameter to django.core.mail.send_mail()

comment:4 Changed 2 years ago by russellm

For the sake of completeness -- yes, I've got the git blame attribution for the "frozen" comments, but I wasn't the original author. The original author of those comments was Malcolm d5d2072bbfc38015a93d6e13136c3f1dbf125d87. He made that change because the intention was to discourage people from using send_mail, and encourage the use of EmailMessage instead. The intention was that Django should only have the bare minimum tools for sending mail; if you wanted more, you should be using Python native features. We had a lot of feature requests on django-users/django-dev to add extra arguments to send_mail; the comment in the code was an attempt to stop those requests.

However, since that time, the world has changed a bit. We've introduced mail backends, which massively increased the scope of the mail APIs in Django. We fixed #10863, which added HTML mail functionality to some (but not all) of the internal mail sending tools. More generally, HTML mails have become a lot more common/acceptable.

comment:5 Changed 2 years ago by Tim Graham <timograham@…>

In d4dd55e78ccc8d38de750313f75d6921137e71ab:

Doc tweaks for html_message parameter to send_mail(); refs #20817

Note: See TracTickets for help on using tickets.
Back to Top