[issue28879] smtplib send_message should add Date header if it is missing, per RFC5322
Eric Lafontaine
report at bugs.python.org
Tue Dec 6 12:34:56 EST 2016
Eric Lafontaine added the comment:
Hi, Not sure this is where the comment goes...
I work with the smtplib and email libraries. I understand Henning von Bargen when he say that we should have a way to support RFC 5322 without asking the user to understand how to support it. The issue is that the SMTP protocol is NOT the protocol that format the e-mail. SMTP is the protocol that identify the "from", the "to", start encryption and finally transfert the message. The actual e-mail content is all passed inside the SMTP "DATA" Command. I strongly believe that an email should not be modified by a SMTP library.
the discussion should be focused on trying to make it available to the user WITHOUT changing the current behavior of email.message class.
In other words, I disagree to change the SMTPlib module and suggest that it's how you construct your email in the first place that should consider it;
class MessageRfc5322(email.message.Message):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.get('Date', None) is None:
self.add_header('Date', email.utils.formatdate())
msg = email.message_from_string(string_message, MessageRfc5322)
But, that's my opinion as someone who uses the smtplib and email library but also need to support rfc822 clients...
----------
nosy: +Eric Lafontaine
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28879>
_______________________________________
More information about the Python-bugs-list
mailing list