Mailing List Archive

Why does SMTP.send_message() do from mangling?
Why does SMTP.send_message(msg) do from mangling even though msg's
policy has mangle_from_ set to False? The msg policy is
email.policy.SMTP which has mangle_from_ disabled.

One might expect that SMTP.send_message(msg) would use either msg's
policy or email.policy.SMTP to send the message, but it does neither.

Don't you think that email.policy.SMTP would be the policy that ought
to be used to serialize a message for sending via SMTP?

None of the other SMTP clients I've checked do from mangling.

AFAICT, in order to send message without from mangling, I have to do
something like this:

s.sendmail(msg['From'], msg['To'], msg.as_bytes())

Instead of

s.send_message(msg)

For simple cases, it doesn't matter much, but if you have multiple
recipients, bcc, and cc, it's a pain that send_message() can't be
used.

What is the purpose of from mangling in an SMTP context?

I understand why it's done when writing messages to mbox files, but
what does that have to do with SMTP.send_message()?

--
Grant
--
https://mail.python.org/mailman/listinfo/python-list
Re: Why does SMTP.send_message() do from mangling? [ In reply to ]
On 2021-09-27, Grant Edwards <grant.b.edwards@gmail.com> wrote:

> Why does SMTP.send_message(msg) do from mangling even though msg's
> policy has mangle_from_ set to False?

I've concluded this is a bug in SMTP.send_message()

https://bugs.python.org/issue45299

--
Grant
--
https://mail.python.org/mailman/listinfo/python-list