Skip to content

Instantly share code, notes, and snippets.

@myl7
Last active July 13, 2022 01:12
Show Gist options
  • Save myl7/95e94cf19388f182bd4194ecff7352d8 to your computer and use it in GitHub Desktop.
Save myl7/95e94cf19388f182bd4194ecff7352d8 to your computer and use it in GitHub Desktop.
SMTP send script for simple email notification
import sys
import smtplib
SMTP_SERVER = 'smtp.mailgun.org'
SMTP_PORT = 587
SMTP_USERNAME = 'notify@noreply.myl.moe'
SMTP_PASSWORD = ''
FROM_ADDR = 'notify@noreply.myl.moe'
TO_ADDRS = ['myl7.moe@gmail.com']
REPORT_LINE_BY_LINE = False
smtp = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
smtp.login(SMTP_USERNAME, SMTP_PASSWORD)
if REPORT_LINE_BY_LINE:
for line in sys.stdin:
smtp.sendmail(FROM_ADDR, TO_ADDRS, line)
else:
smtp.sendmail(FROM_ADDR, TO_ADDRS, sys.stdin.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment