#28726: Brackets illegal in DEFAULT_FROM_EMAIL name part
-------------------------------------+-------------------------------------
     Reporter:  Ciaran Courtney      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Mail)          |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  email                |             Triage Stage:  Accepted
  DEFAULT_FROM_EMAIL                 |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jani Sumak):

 * stage:  Unreviewed => Accepted


Old description:

> Using `DEFAULT_FROM_EMAIL = '[test] Bob <[email protected]>'` will fail
> in django.core.mail.message.sanitize_address() at
> `parseaddr(force_text(addr))`
>
> Possibly other characters are illegal. The docs don't mention the use of
> DEFAULT_FROM_EMAIL in this way, perhaps documentation can cover it.

New description:

 Using `DEFAULT_FROM_EMAIL = '[test] Bob <[email protected]>'` will fail
 in django.core.mail.message.sanitize_address() at `parseaddr(addr)`

 Possibly other characters are illegal. The docs don't mention the use of
 DEFAULT_FROM_EMAIL in this way, perhaps documentation can cover it.

--

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. `parseaddr`will 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', '[email protected]')]`. Since
 `sanitize_address`will 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 protected]>`.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28726#comment:1>
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/072.2d192b2f8308e812cdd09375a0721255%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to