Skip to content

Instantly share code, notes, and snippets.

@APTy
Created March 25, 2016 18:41
Show Gist options
  • Save APTy/4264ec8126ad0c0925e2 to your computer and use it in GitHub Desktop.
Save APTy/4264ec8126ad0c0925e2 to your computer and use it in GitHub Desktop.
import smtplib
import email.mime.text as text
TARGETS = ['me@example.com',]
def notify(targets, subject, message):
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login('yoursenderemail@gmail.com', 'yourpassword')
for target in targets:
msg = text.MIMEText(message)
msg['Subject'] = subject
msg['From'] = 'yoursenderemail@gmail.com'
msg['To'] = target
server.send_message(msg)
server.quit()
notify(TARGETS, 'hello', 'hello this is a test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment