import smtplib
username = 'user'
password = 'pwd'
from_addr = 'username@gmail.com'
to_addrs = 'username@gmail.com'
msg = "
".join([
"From: username@gmail.com",
"To: username@gmail.com",
"Subject: subject",
"",
"message"
])
server = smtplib.SMTP('YOUR_SMTP_EMAIL_ADDRESS')
server.ehlo()
server.starttls()
server.login(username, password)
server.sendmail(from_addr, to_addrs, msg)
server.quit()