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