#!/usr/bin/env python def SendEmail(From,To,Subject,Text) : """ Very simple email method adapted from: http://stackoverflow.com/questions/882712/sending-html-email-using-python There are more elaborate examples on this site for sending HTML messages and attachments. """ import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText Host = 'localhost' msg = MIMEMultipart('alternative') msg['Subject'] = Subject Html = """\

%s

""" %(Text) part1 = MIMEText(Text, 'plain') part2 = MIMEText(Html, 'html') msg.attach(part1) msg.attach(part2) try: server = smtplib.SMTP(Host) server.sendmail(From, To, msg.as_string()) server.quit() print "Successfully sent email" except : print "Error: unable to send email" FPATH='/home/psgendb/GenBank/update_blastdb.log' Infile = open(FPATH, 'r') Text = "Output from BLupdate_blastdb.py \n" for line in Infile.readlines() : Text = Text + line + '
' Infile.close() adminEmail='psgendb@cc.umanitoba.ca' Subject = 'Python Email Test' SendEmail(adminEmail,[adminEmail],Subject,Text)