Opened 9 years ago

Closed 8 years ago

#3985 closed (fixed)

send_mail user-defined headers

Reported by: ido Owned by: adrian
Component: Core (Mail) Version: master
Severity: Keywords: custom headers
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:


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 (3)

mail-additional_headers.diff (2.1 KB) - added by meren@… 9 years ago.
work also with additional headers if there is any..
mail-additional_headers.2.diff (2.1 KB) - added by meren@… 9 years ago.
less messy..
mail-additional_headers.3.diff (4.3 KB) - added by SmileyChris 9 years ago.
backwards compatibility and documentation

Download all attachments as: .zip

Change History (8)

Changed 9 years ago by meren@…

work also with additional headers if there is any..

comment:1 Changed 9 years ago by meren@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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, should be redesigned from scratch.

I just wanted to share,

comment:2 Changed 9 years ago by SmileyChris

  • Has patch set
  • Summary changed from what about user-defined headers? to send_mail user-defined headers
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 9 years ago by mtredinnick

  • Patch needs improvement set
  • Triage 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.

Changed 9 years ago by meren@…

less messy..

Changed 9 years ago by SmileyChris

backwards compatibility and documentation

comment:4 Changed 9 years ago 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?

comment:5 Changed 8 years ago by mtredinnick

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

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

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