[issue28879] smtplib send_message should add Date header if it is missing, per RFC5322

R. David Murray report at bugs.python.org
Fri Dec 16 15:40:29 EST 2016


R. David Murray added the comment:

The signature of send_message cannot be changed for backward compatibility reasons.  It's signature was not intended to be an extension of the sendmail signature.

send_message cannot accept a dictionary, as then it would have to know how to format that dictionary into an RFC5322 compliant text string.  Nor can a dictionary represent a collection of email headers accurate.  Representing the headers and doing the serialization is the email package's job.

It is true that the ehlo_or_helo_if_needed is technically redundant, however, what it means is that once you've called any smtplib command you know that has been done, even if the subcommand raises an error.  This can make debuging easier (consistency of state), at a trivial cost.

The "more than one Resent block" error is explained in the comments.  If you want to write the heuristics to remove it, go ahead :)

Looking at that code, I see that I misremembered what it was doing.  I thought it was adding Resent-Date if it was missing, but it is instead determining what form of address headers it needs to add if Reset-Date is present.  That doesn't change the analysis in this issue, though.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28879>
_______________________________________


More information about the Python-bugs-list mailing list