Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32907 closed New feature (invalid)

Allow duplicate headers while sending email

Reported by: Shrawan Poudel Owned by: nobody
Component: Core (Mail) Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Currently, for sending custom headers while sending email we create up a dict and pass it to the EmailMessage

for example:

from django.core.mail import EmailMessage

email = EmailMessage(
    'Example Subject',
    'Here is the message.',
    headers={'x-unique-id':  'unique_id',
                     'X-email-id-trace ':'trace_id'},

Since we pass headers using a dict i need to create up unique keys for headers so this is the reason i am not being able to send duplicate email headers,
i came across this case when i tried to implement AWS SES Logging where i need to send multiple headers of same name like,

    headers={'X-SES-CONFIGURATION-SET':  'emailLogs',
                     'X-SES-MESSAGE-TAGS ':'uid=uid',

There are/can be multiple workarounds to deal with it but i will be happy to see this implemented in django core itself

I am happy to work on it if it needs to be implemented as a new feature to allow duplicate headers name

Change History (3)

comment:1 by Adam Johnson, 3 years ago

I checked the RFC ( ) and only certain email headers are listed as allowed to occur more than one time. The SES header does not appear there.

I checked the SES documentation and it recommends passing multiple tags in one header, separated by commas. This may be what you want to do:

comment:2 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

IMO there is no need for a new API, you should be able to pass multiple values in a single string, e.g. 'X-SES-MESSAGE-TAGS ': 'uid=uid, sub=sub, dom=dom', see also TicketClosingReasons/UseSupportChannels for ways to get help.

comment:3 by Mariusz Felisiak, 3 years ago

Thanks Adam for extra details.

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