· 9 years ago · Jan 19, 2017, 07:54 PM
1import smtplib
2
3email_to = '*****@gmail.com'
4username = '*******@outlook.com'
5password = '*********'
6other_email = '*******@outlook.com'
7
8mail = smtplib.SMTP('Outlook.com', 25)
9mail.ehlo()
10mail.starttls()
11mail.login(username,password)
12
13header = 'To:' + email_to + 'n' +'From: ' + other_email + 'n' + 'Subject: Python Project Testn'
14message = header + 'nn This is a test message generated from a Python script. nn'
15
16mail.sendmail(username, email_to, message)
17mail.close()
18print("Email sent successfully.")