I'm trying to send myself an email using Python's smtplib module. Here's the code I'm trying to execute:
import smtplib
sender = 'manas.oid@gmail.com'
receivers = ['manas.oid@gmail.com']
message = """From: From Person <manas.oid@gmail.com>
To: To Person <manas.oid@gmail.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except smtplib.SMTPException:
print "Error: unable to send email"
However, I get a 'Error:unable to send email' message when I try to execute this script. What seems to be wrong with my script?