Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Error: 5.7.0 must issue a starttls command first

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.

like image 329
user2142166 Avatar asked Jun 07 '13 10:06

user2142166


1 Answers

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.

like image 155
kirelagin Avatar answered Oct 22 '22 01:10

kirelagin