Wouldn’t it be great to get an email once a script has finished letting you know if it worked or failed? Well it’s actually really easy to pull off. Here’s how I did it:
Note for this example you would replace ‘smtp.example.com’ with your email host.
def SendEmail(sender, receivers, message): import sys, smtplib try: smtpObj = smtplib.SMTP('smtp.example.com') smtpObj.sendmail(sender, receivers, message) print 'email sent' except: print 'error sending' sys.exit
message = "my output message" + output #for example. use whatever you want here to convey the info you need receivers = "firstname.lastname@example.org" sender = "email@example.com" SendEmail(sender, receivers, message)