You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When sending a mail using repoze.sendmail.mailer.SMTPMailer.send( fromaddr, toaddrs, message), the message will be encoded (message = encode_message(message)) and then sent (connection.sendmail(fromaddr, toaddrs, message)).
the encode_message function calls message.as_string(), which concatenates all headers and body using LF, the default line separator of the email policy. https://docs.python.org/3/library/email.message.html states:
"If policy is specified use the rules it specifies to update and serialize the representation of the message. If policy is not set, use the default policy, which follows the rules of the email RFCs except for line endings (instead of the RFC mandated \r\n, it uses the Python standard \n line endings). For more information see the policy documentation."
When sending a mail using
repoze.sendmail.mailer.SMTPMailer.send( fromaddr, toaddrs, message)
, the message will be encoded (message = encode_message(message)
) and then sent (connection.sendmail(fromaddr, toaddrs, message)
).the
encode_message
function callsmessage.as_string()
, which concatenates all headers and body using LF, the default line separator of the email policy. https://docs.python.org/3/library/email.message.html states:https://www.rfc-editor.org/rfc/rfc5322#section-2.1
So, using this without extra handling causes the mail to be sent not conforming to RFC5322.
https://docs.python.org/3/library/email.policy.html#module-email.policy gives a hint how to solve it.
I guess instead of
encoding.py encode_message() line 103:
return message.as_string().encode('ascii')
we need something like
(I copied the contents of the as_string method, adding
message.policy.clone(linesep='\r\n')
and replacingself
withmessage
)The text was updated successfully, but these errors were encountered: