R. David Murray added the comment:

As I implied but did not say explicitly, this is the expected behavior of 
smtplib.  You are responsible for adding any headers to the message that you 
want smtplib to send.  In particular, the 'sendmail' method takes a string to 
send, and smtplib does not modify it except for cr/lf transformation.  smtplib 
does not itself understand RFC5322 message syntax.

We can, however, add a Date header in the new send_message method of the 
python3 email library, because it accepts a Message object, and smtplib can use 
the knowledge the Message object encapsulates to check for the Date header and 
add one if it is missing.  That's why I've left this issue open.  I have now 
adjusted versions accordingly (ie: this is not a bug in python2.7, it is an 
enhancement request for Python3).  Sorry I wasn't clear about this earlier.

Hmm.  Actually, we can argue that it is an RFC compliance issue, as you have 
suggested, and change it in 3.6 as well, since it isn't likely to break 
anyone's working code.  So I'll put 3.6 in the versions unless someone objects 
to that logic.  But even after this is changed in python3, the smtplib sendmail 
method will not add a Date header, only the send_message method.

----------
keywords: +easy
title: smtplib RFC 5322 date header missing -> smtplib send_message should add 
Date header if it is missing, per RFC5322
type:  -> behavior
versions: +Python 3.6, Python 3.7 -Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28879>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to