Changes between Initial Version and Version 1 of Ticket #28726


Ignore:
Timestamp:
Oct 25, 2017, 10:14:58 AM (7 years ago)
Author:
Jani Sumak
Comment:

If from_email is not provided, EmailMessage or EmailMultiAlternatives will use DEFAULT_FROM_EMAIL. If DEFAULT_FROM_EMAIL is not a tuple sanitize_address will pass DEFAULT_FROM_EMAIL to the function parseaddr from the email module in the standard library. parseaddrwill then try to parse RFC 2822 addresses.

Space and "(),:;<>@[\] characters are allowed with restrictions (https://stackoverflow.com/a/2049510/4819353). If you pass a suqare bracket [ to parseaddr it will return someting like this: [('', ''), ('', 'test'), ('', ''), ('Bob', 'noreply@example.com')]. Since sanitize_addresswill use only the first element from the returned list, you will get an error.

I suggest that the documentation mentions some of this.

DEFAULT_FROM_EMAIL¶
...

The value should be a tuple containing two strings, `(name, address)`,  or a string in the form of `name <email@example.com>`.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28726

    • Property Triage Stage UnreviewedAccepted
  • Ticket #28726 – Description

    initial v1  
    1 Using `DEFAULT_FROM_EMAIL = '[test] Bob <noreply@example.com>'` will fail in django.core.mail.message.sanitize_address() at `parseaddr(force_text(addr))`
     1Using `DEFAULT_FROM_EMAIL = '[test] Bob <noreply@example.com>'` will fail in django.core.mail.message.sanitize_address() at `parseaddr(addr)`
    22
    33Possibly other characters are illegal. The docs don't mention the use of DEFAULT_FROM_EMAIL in this way, perhaps documentation can cover it.
Back to Top