#28912: EmailMessage.message() should not set a blank To: field when
EmailMessage.to is empty
------------------------------------------------+------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Mail) | Version: master
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 |
------------------------------------------------+------------------------
`EmailMessage.message()` always sets a `To:` header, see:
https://github.com/django/django/blob/a9e5ac823df8ba8b786b6450c967ca378c008d0e/django/core/mail/message.py#L257
In my project, emails are sent to `Cc:` or `Bcc:` recipients without a
`To:` recipient.
Some mail backends are very strict about allowed headers and their values.
For example, Amazon Simple Email Service (SES) validates all recipient
headers to contain valid email addresses. It fails without delivery if any
header contains an invalid address. For some details, see:
https://boto3.readthedocs.io/en/latest/reference/services/ses.html#SES.Client.send_raw_email
> The message must include at least one recipient email address. The
recipient address can be a To: address, a CC: address, or a BCC: address.
If a recipient email address is invalid (that is, it is not in the format
UserName@[SubDomain.]Domain.TopLevelDomain ), the entire message will be
rejected, even if the message contains other recipients that are valid.
SES considers blank as invalid. When sending an email serialized by
`EmailMessage.message()` to `Cc:` or `Bcc:` only addresses, SES fails with
an error. `To:` avoid the error, Django can avoid setting the To header
when `EmailMessage.to` is empty.
--
Ticket URL: <https://code.djangoproject.com/ticket/28912>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.27efcbb73a18e4fe08aeddccf108baa7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.