#!/usr/bin/env python import smtplib import datetime def main(): delta = datetime.datetime(2016, 10, 2, 13, 00, 00) - datetime.datetime.now() sender = 'jaimesantos23@gmail.com' receivers = ['jaimesantos23@gmail.com'] message = """From: From Person To: To Person Subject: You have %s days and %s seconds for the 400-101 exam! Appointment Sunday, October 2, 2016 Start Time: 01:00 PM BST Location Work4u Global LTD Radial House, 2nd floor (Halifax Bank) 3 Ripple Road Barking Essex IG11 7NP United Kingdom . """ message1=(message % (delta.days,delta.seconds)) username = 'jaimesantos23@gmail.com' password = 'Ch@t@p0o9i8' try: smtpObj = smtplib.SMTP('smtp.gmail.com:587') smtpObj.ehlo() smtpObj.starttls() smtpObj.login(username,password) smtpObj.sendmail(sender, receivers, message1) print "Successfully sent email" except smtplib.SMTPException: print 'Error: unable to send email' if __name__ == '__main__': # sys.exit(main(sys.argv)) # used to give a better look to exists main()