Last active
July 13, 2022 01:12
-
-
Save myl7/95e94cf19388f182bd4194ecff7352d8 to your computer and use it in GitHub Desktop.
SMTP send script for simple email notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import smtplib | |
SMTP_SERVER = 'smtp.mailgun.org' | |
SMTP_PORT = 587 | |
SMTP_USERNAME = '[email protected]' | |
SMTP_PASSWORD = '' | |
FROM_ADDR = '[email protected]' | |
TO_ADDRS = ['[email protected]'] | |
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