Reputation: 870
I'm writing a simple script to send email with inline picture in Python 3.5; because I'm a beginner I take the example on the official doc: 19.1.14.1. Examples using the Provisional API
Well, the generated email can be correctly read by Thunderbird but not on other email clients like Apple Mail and Gmail web based email.
Comparing the same message (with the same attachment) it seems that the inline attachment is encoded differently.
On the example only the line:
with open("roasted-asparagus.jpg", 'rb') as img:
msg.get_payload()[1].add_related(img.read(), 'image', 'jpeg', cid=asparagus_cid)
...should make the magic to read the jpg and encode it properly.
smtplib
) seems too much low level... in PHP there is PHPMailer: Something similar in Python?Thanks for answer.
Upvotes: 0
Views: 158
Reputation: 870
Python 3.5 libraries have issues generating Base64 encoded attachments; all the discussion is here: python forum discussion.
I solved simply upgrading Python to version 3.6 and worked correctly.
Note also that email generated (with code taken from official documentation) and libraries v. 3.5 has an higher spam point to the one generated with libraries v. 3.6.
As usual any other thought is the welcome.
Upvotes: 1