[Django] #32907: Allow duplicate headers while sending email

0 views
Skip to first unread message

Django

unread,
Jul 6, 2021, 5:46:02 AM7/6/21
to django-...@googlegroups.com
#32907: Allow duplicate headers while sending email
------------------------------------------+------------------------
Reporter: Shrawan Poudel | Owner: nobody
Type: New feature | Status: new
Component: Core (Mail) | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
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.',
'fr...@example.com',
to=['t...@example.com'],
headers={'x-unique-id': 'unique_id',
'X-email-id-trace ':'trace_id'},
)
email.send(fail_silently=False)
}}}

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',
'X-SES-MESSAGE-TAGS':'sub=sub',
'X-SES-MESSAGE-TAGS':'dom=dom'},

}}}

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

--
Ticket URL: <https://code.djangoproject.com/ticket/32907>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 6, 2021, 6:12:10 AM7/6/21
to django-...@googlegroups.com
#32907: Allow duplicate headers while sending email
--------------------------------+--------------------------------------

Reporter: Shrawan Poudel | Owner: nobody
Type: New feature | Status: new
Component: Core (Mail) | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Adam Johnson):

I checked the RFC (
https://datatracker.ietf.org/doc/html/rfc5322#section-3.6 ) 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:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-
send-email.html#event-publishing-using-ses-headers

--
Ticket URL: <https://code.djangoproject.com/ticket/32907#comment:1>

Django

unread,
Jul 6, 2021, 6:13:33 AM7/6/21
to django-...@googlegroups.com
#32907: Allow duplicate headers while sending email
--------------------------------+--------------------------------------

Reporter: Shrawan Poudel | Owner: nobody
Type: New feature | Status: closed

Component: Core (Mail) | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32907#comment:2>

Django

unread,
Jul 6, 2021, 6:13:56 AM7/6/21
to django-...@googlegroups.com
#32907: Allow duplicate headers while sending email
--------------------------------+--------------------------------------

Reporter: Shrawan Poudel | Owner: nobody
Type: New feature | Status: closed

Component: Core (Mail) | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

Thanks Adam for extra details.

--
Ticket URL: <https://code.djangoproject.com/ticket/32907#comment:3>

Reply all
Reply to author
Forward
0 new messages