Skip to content

bpo-28879 : add date if missing in smtplib.send_message #2655

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-28879 : add date if missing in smtplib.send_message part 2
Fix the whitespace and spacing
  • Loading branch information
elafontaine committed Jul 11, 2017
commit 9a8cdc2670427c61bb49b2575be019b0f8b4ae94
2 changes: 1 addition & 1 deletion Doc/library/smtplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ An :class:`SMTP` instance has the following methods:
specified in :rfc:`5322`\: *from_addr* is set to the :mailheader:`Sender`
field if it is present, and otherwise to the :mailheader:`From` field.
*to_addrs* combines the values (if any) of the :mailheader:`To`,
:mailheader:`Cc`, and :mailheader:`Bcc` fields from *msg*. If there's no
:mailheader:`Cc`, and :mailheader:`Bcc` fields from *msg*. If there's no
*Date* header inside the message, ``send_message`` will add one to the data.
If exactly one
set of :mailheader:`Resent-*` headers appear in the message, the regular
Expand Down
5 changes: 2 additions & 3 deletions Lib/smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,11 @@ def send_message(self, msg, from_addr=None, to_addrs=None,
header_prefix = 'Resent-'
else:
raise ValueError("message has more than one 'Resent-' header block")

# RFC 5322 section 3.6, 4th Paragraph
if msg.get('Date',None) is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here missing a whitespace after the ,.

msg['Date'] = email.utils.formatdate()



if from_addr is None:
# Prefer the sender field per RFC 2822:3.6.2.
from_addr = (msg[header_prefix + 'Sender']
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,6 @@ def testSendMessageAddDateIfMissing(self):
self.assertRegex(debugout, Date)




class NonConnectingTests(unittest.TestCase):

def testNotConnected(self):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy