Skip to content

Instantly share code, notes, and snippets.

@sgs00
Forked from rotated8/email.py
Last active August 29, 2015 14:19
Show Gist options
  • Save sgs00/bd59ae052b1676d1b558 to your computer and use it in GitHub Desktop.
Save sgs00/bd59ae052b1676d1b558 to your computer and use it in GitHub Desktop.
from email.mime.text import MIMEText
import smtplib
gmail_username = 'username@gmail.com'
recipients = 'recipient@example.com'
# https://en.wikipedia.org/wiki/List_of_SMS_gateways
# 10DigitNumber@text.att.net for AT&T
# 10DigitNumber@vtext.com for Verizon
msg = MIMEText('This is the body of the message.')
msg['Subject'] = 'Blank subject lines look like spam.'
msg['From'] = gmail_username
msg['To'] = recipients
msg = msg.as_string()
session = smtplib.SMTP('smtp.gmail.com', 587)
session.ehlo()
session.starttls()
session.login(gmail_username, 'your-gmail-or-application-specific-password')
session.sendmail(gmail_username, recipients, msg)
session.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment