A Python nugget from Programming Your Home (review) I wanted to share from p97:
import smtplib def send_email(subject, message) recipient = 'your_email_recipient@domain.tld' gmail_sender = 'your_gmail_account@gmail.com' gmail_password = 'your_gmail_password' #use tls gmail_smtp = smtplib.SMTP('smtp.gmail.com', 587) gmail_smtp.ehlo() gmail_smtp.starttls() gmail_smtp.ehlo() #login gmail_smtp.login(gmail_send, gmail_password) #message formatting mail_header = 'To: ' + recipient + '\n' + 'From: ' + gmail_sender + '\n' + 'Subject: ' + subject + '\n' message_body = message mail message = mail_header + '\n ' + message_body + '\n\n' #send gmail_smtp.sendmail(gmail_sender, recipient, mail_message) #close gmail_smtp.close()