Django

Code

Ticket #3985 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

send_mail user-defined headers

Reported by: ido Assigned to: adrian
Milestone: Component: django.core.mail
Version: SVN Keywords: custom headers
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description

How do send_mail, send_mass_mail, etc. permit one to define custom headers (such as for S/MIME, List-Id, etc.) in the outgoing email message?

This is a critical component of sending email that should not be overlooked in these docs.

Attachments

mail-additional_headers.diff (2.1 kB) - added by meren@pardus.org.tr on 04/10/07 08:39:05.
work also with additional headers if there is any..
mail-additional_headers.2.diff (2.1 kB) - added by meren@pardus.org.tr on 04/24/07 03:05:17.
less messy..
mail-additional_headers.3.diff (4.3 kB) - added by SmileyChris on 04/24/07 04:20:34.
backwards compatibility and documentation

Change History

04/10/07 08:39:05 changed by meren@pardus.org.tr

  • attachment mail-additional_headers.diff added.

work also with additional headers if there is any..

04/10/07 08:51:06 changed by meren@pardus.org.tr

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

I'm using django with this, 'mail-additional_headers.diff' patch to be able to pass additional headers to the mails.

import django.core.mail as mailer

(...)

hdict = {"Reply-To": reply_to_addr, 'List-ID': list_id}
mailer.send_mail(sbj, msg, from, recipient_list, additional_headers_dict=hdict)

I know that this is a very dirty way to do this but at least it works for me and not breaks anything. Also IMHO, mail.py should be redesigned from scratch.

I just wanted to share, Thanks.

04/10/07 22:41:11 changed by SmileyChris

  • has_patch set to 1.
  • summary changed from what about user-defined headers? to send_mail user-defined headers.
  • stage changed from Unreviewed to Design decision needed.

04/24/07 02:18:46 changed by mtredinnick

  • needs_better_patch set to 1.
  • stage changed from Design decision needed to Accepted.

A low priority change (after all, you have access to all of Python's mail infrastructure if you want it), but may be worth adding. I'm probably about +0.5 on this.

The patch needs improvement, though. There must be a less messy way to write the change at line 88.

04/24/07 03:05:17 changed by meren@pardus.org.tr

  • attachment mail-additional_headers.2.diff added.

less messy..

04/24/07 04:20:34 changed by SmileyChris

  • attachment mail-additional_headers.3.diff added.

backwards compatibility and documentation

05/08/07 18:29:30 changed by anonymous

Would there be any interest in renaming additional_headers_dict to something shorter? It's a little verbose. Perhaps something like extra_headers?

06/27/07 07:41:37 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5550]) Fixed #3985 -- Added support for custom email headers.


Add/Change #3985 (send_mail user-defined headers)




Change Properties
Action