import smtplib
sender = '
[email protected]'
receivers = ['
[email protected]']
message = """From: From Person <
[email protected]>
To: To Person <
[email protected]>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print ("email sent Successfully")
except SMTPException:
print ("Error: unable to send email")