This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: email examples: incorrect use of email.headerregistry.Address
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: EmailMessage example doesn't work
View: 26176
Assigned To: docs@python Nosy List: barry, berker.peksag, docs@python, jwilk
Priority: normal Keywords:

Created on 2016-02-24 13:37 by jwilk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg260796 - (view) Author: Jakub Wilk (jwilk) Date: 2016-02-24 13:37
https://docs.python.org/3/library/email-examples.html#examples-using-the-provisional-api contains the following code:

from email.headerregistry import Address
...
msg['From'] = Address("Pepé Le Pew", "pepe@example.com")
msg['To'] = (Address("Penelope Pussycat", "penelope@example.com"),
             Address("Fabrette Pussycat", "fabrette@example.com"))

But Address takes just the username, not the whole email address, as the second argument. So this should be written as:

msg['From'] = Address("Pepé Le Pew", "pepe", "example.com")
...

or:

msg['From'] = Address("Pepé Le Pew", addr_spec="pepe@example.com")
...
msg260797 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-02-24 13:45
Thanks for the report. This is a duplicate of issue 26176. Would you like to send a patch?
History
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70613
2016-02-24 13:53:53barrysetnosy: + barry
2016-02-24 13:45:47berker.peksagsetstatus: open -> closed

superseder: EmailMessage example doesn't work

nosy: + berker.peksag
messages: + msg260797
resolution: duplicate
stage: resolved
2016-02-24 13:37:42jwilkcreate