Jul-24-2020, 12:42 AM
I stole the example from here: https://docs.python.org/3/library/email.examples.html
Looks like it will base64 encode the message if it needs to, so that it's just sending ascii. Hopefully this helps.
Looks like it will base64 encode the message if it needs to, so that it's just sending ascii. Hopefully this helps.
>>> import smtplib >>> from email.message import EmailMessage >>> msg = EmailMessage() >>> msg.set_content("ç - testing - ç") >>> msg["Subject"] = "email test" >>> msg['From'] = "[email protected]" >>> msg['To'] = "[email protected]" >>> msg.as_string() 'Content-Type: text/plain; charset="utf-8"\nContent-Transfer-Encoding: base64\nMIME-Version: 1.0\nSubject: email test\nFrom: [email protected]\nTo: [email protected]\n\nw6cgLSB0ZXN0aW5nIC0gw6cK\n' >>> s = smtplib.SMTP('localhost') #or wherever >>> s.send_message(msg) >>> s.quit()