[issue25235] EmailMessage.add_attachment() creates parts with spurious MIME-Version header.

Barry A. Warsaw report at bugs.python.org
Sat Sep 24 17:50:35 EDT 2016


Barry A. Warsaw added the comment:

On Sep 24, 2016, at 05:06 PM, R. David Murray wrote:

>Barry, would you care to render an opinion on this proposed fix?

I think the general approach is probably the best you can do.  I noticed a
couple of things though with RDM's v.2 patch.

First, I get test failures when applying to the 3.5 branch, specifically
test_mime_version_added_to_mime_message() fails.  I won't attach the failure
I'm seeing unless you can't reproduce it.

Second, if I'm reading RFC 2045#section-4 correctly, I think the embedded
rfc822 attachment should have a MIME-Version header, in this code:

-----snip snip-----
from email.message import EmailMessage

m = EmailMessage()
m.set_content('This is a body')

o = EmailMessage()
o.add_attachment(m)

print(o)

print(m['mime-version'])
-----snip snip-----

But instead I get:

Content-Type: multipart/mixed; boundary="===============4744209610526815348=="
MIME-Version: 1.0

--===============4744209610526815348==
Content-Type: message/rfc822
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment

MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

This is a body

--===============4744209610526815348==--

1.0

----------

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


More information about the Python-bugs-list mailing list