Last active
August 29, 2015 14:15
-
-
Save carpedm20/b88e989f3d1400e7a9f2 to your computer and use it in GitHub Desktop.
Mail notification
This file contains 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
#!/usr/bin/python | |
import smtplib | |
from email.mime.text import MIMEText | |
import netrc | |
from docopt import docopt | |
DEFAULTFROM = "admin@minsky.unist.ac.kr" | |
DEFAULTTO = "carpedm20@gmail.com" | |
SMSADDRESS = "carpedm20@messaging.sprintpcs.com" | |
DEFAULTSUBJECT = "Job finished from PAIL Minsky" | |
def send_email(message="Job finished",subject=DEFAULTSUBJECT, | |
me=DEFAULTFROM,recipients=[DEFAULTTO], | |
smtpserver="localhost",login=None,password=None): | |
msg = MIMEText(message) | |
msg['Subject'] = subject | |
msg['From'] = me | |
msg['To'] = ", ".join(recipients) | |
s = smtplib.SMTP(smtpserver) | |
s.sendmail(me,recipients, msg.as_string()) | |
s.quit() | |
if __name__=="__main__": | |
toaddr = DEFAULTTO | |
fromaddr = DEFAULTFROM | |
subject = DEFAULTSUBJECT | |
send_email(recipients=[toaddr], me=fromaddr, subject=subject) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment