Feb-23-2018, 05:05 PM
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:
...should make the magic to read the jpg and encode it properly.
Anybody with similar experiences and / or suggestions?
There is a complete Python high level library to correctly handle the building and sending of emails with attachments? The built in library (
Thanks for answer.
Francesco
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:
1 2 |
with open ( "roasted-asparagus.jpg" , 'rb' ) as img: msg.get_payload()[ 1 ].add_related(img.read(), 'image' , 'jpeg' , cid = asparagus_cid) |
Anybody with similar experiences and / or suggestions?
There is a complete Python high level library to correctly handle the building and sending of emails with attachments? The built in library (
smtplib
) seems too much low level... in PHP there is PHPMailer: Something similar in Python?Thanks for answer.
Francesco