# connect to your Email-Server and send Hello Message (ehlo) smtpObj = smtplib.SMTP('smtp.example.com', 587) smtpObj.ehlo() # start TLS encryption for security smtpObj.starttls() # login to the Email-Server with your own username/password smtpObj.login('bob@example.com', 'PASSWORD') # send Email from Bob to Alice. Email-Headers are text-fields on separate lines. # the Email-Body is separated by an empty line from the header. smtpObj.sendmail('bob@example.com', 'alice@example.com', 'Subject:Just a Test\nDate:20171208\nFrom:bob@example.com\n\nThis is a test-mail. Ignore!') # disconnect from Mailserver smtpObj.quit()