R. David Murray added the comment:

The sendmail function will never modify the RFC822+ content.  send_message, 
however, already does several manipulations of the message headers to make 
sending email simpler.  Practicality (make it easy to send messages without 
knowing the details of the SMTP/RFC5322 rules) beats purity (an SMTP library 
should not modify the content of the DATA) in this case, especially since 
smtplib *does* provide the purity version if you prefer to work that way.

That is, 'sendmail' is pure SMTP, while send_message is a practical enhancement 
that provides additional services to the caller, and can (and does and probably 
should) do checks for RFC required headers.

If someone wants to do a purity refactor (to which I would not object, and 
would in fact encourage), the RFC5322-aware code could be factored out into one 
or more functions or Message object methods in the email library that smtplib 
would call from the send_message method.

My visualization is that the email library should allow you to construct a 
valid email in whatever order you want (adding the Date header late in the 
process, for example), but should support validating the email before it is 
sent.  One way to do this would be to have the SMTP policy do the unambiguous 
fixups such as date headers, and raising errors for the rest (probably only if 
the strict flag is on, at this point) when the message is serialized.

Note that we previously fixed send_message to add a Resent-Date header if there 
are Resent- headers and no Resent-Date, so the precedent is already set (that 
is, smptlib send_message is already "not pure" :)

----------

_______________________________________
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