Issue 31831: EmailMessage.add_attachment(filename ... - Python
bugs.python.org › issue31831Oct 21, 2017 · The following code excerpt demonstrates a crash: import email.message mail = email.message.EmailMessage() mail.add_attachment( b"test", maintype = "text", subtype = "plain", filename = "I thought I could put a few words in the filename but apparently it does not go so well.txt" ) print(mail) Output on python 3.7.0a1: https://gist.github.com/altendky/33c235e8a693235acd0551affee0a4f6 Output on python 3.6.2: https://oremilac.tk/paste/python-rfc2231-oops.log Additionally, a behavioral issue is ...
python - How to send email attachments? - Stack Overflow
stackoverflow.com › questions › 3362600Jul 29, 2010 · import os.path import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.application import MIMEApplication def send_email(subject, message, from_email, to_email=[], attachment=[]): """ :param subject: email subject :param message: Body content of the email (string), can be HTML/CSS or plain text :param from_email: Email address from where the email is sent :param to_email: List of email recipients, example: ["a@a.com", "b@b.com ...