Skip to main content

Send Mail by Python smtplib

  • Python example: Send Mail
import smtplib
from email.mime.text import MIMEText

mailFrom = 'doraemon+from@gmail.com'
mailTo = 'doraemon+to@gmail.com'

msg = MIMEText("test")
msg['Subject'] = 'Subject Test'
msg['From'] = mailFrom
msg['To'] = mailTo

s = smtplib.SMTP('mail.server.edf.org')
s.sendmail(mailFrom, [mailTo], msg.as_string())
s.quit()