Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smtplib email example should contain a "Date" header #107809

Open
Tuxicoman2 opened this issue Aug 9, 2023 · 1 comment
Open

smtplib email example should contain a "Date" header #107809

Tuxicoman2 opened this issue Aug 9, 2023 · 1 comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes docs Documentation in the Doc dir topic-email

Comments

@Tuxicoman2
Copy link

Tuxicoman2 commented Aug 9, 2023

Documentation

https://docs.python.org/3/library/email.examples.html#email-examples is providing code examples.
But those are 'incorrect' as they miss the "Date" header.
Without it, the mail recipient server will reject the email (Amavis/SpamAssassin is dropping the email due to a 'BAD-HEADER-0' error. I experienced that with : https://docker-mailserver.github.io/docker-mailserver/latest/ )

Related topic:

The correct headers in the examples should be:

msg = EmailMessage()
msg['Subject'] = "subject"
msg['From'] = "sender@example.com"
msg['To'] = "receiver@example2.com"
msg["Date"] = email.utils.formatdate(localtime=True)

I understand it's not "added automatically" but the examples could contain that. So a user can get it right the first time without wondering why emails are not received without any error as only the mail receiver server log would tell...

Linked PRs

@Tuxicoman2 Tuxicoman2 added the docs Documentation in the Doc dir label Aug 9, 2023
@AA-Turner
Copy link
Member

I'm unsure if we have a duty in our documentation to ensure that the reader can get past the spam filter de jour; but this seems a fairly innocuous change -- we could make it.

A

@AA-Turner AA-Turner added 3.11 only security fixes topic-email 3.12 bugs and security fixes 3.13 new features, bugs and security fixes labels Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes docs Documentation in the Doc dir topic-email
Projects
None yet
Development

No branches or pull requests

2 participants