· 9 years ago · Jan 19, 2017, 09:44 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'
14 + 'Subject: Python Project Testn')
15message = (header +
16 'nn This is a test message generated from a Python script. nn')
17
18mail.sendmail(username, email_to, message)
19mail.close()
20print("Email sent successfully.")