I try to send an email with my python script, but I got the error message:
5.7.0 must issue a starttls command first
I'm using smtplib
and this is my code:
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('smtp.gmail.com')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except Exception,e:
print str(e)
If some one have an idea about how to solve this error I'll be grateful.
GMail won't let random users send mail through their SMTP servers.
As the error says, you'll have to call SMTP.starttls
first and authenticate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With