user3054652
user3054652

Reputation: 9

Strange error in python using SMTPLIB module

still having issues. I just added some code which uses the smtplib module to send an email to the email address that has been entered by the user, however I got this error

File "C:\Python27\lib\smtplib.py", line 555, in login raise SMTPException("SMTP AUTH extension not supported by server.") SMTPException: SMTP AUTH extension not supported by server.

The code I used was from a beginners website

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)


server.login("youremailusername", "password")
msg = "\nHello!"
server.sendmail("[email protected]", "[email protected]", msg)

However in my case, I used the name of a variable which holds the email or the user where it says "target @example.com" Help someone? ALso I would like to know what are the numbers that come after "smtp.gmail.com"? The 587?

Upvotes: 0

Views: 283

Answers (1)

Hackaholic
Hackaholic

Reputation: 19763

you need to add this server.starttls() before login

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()         
server.login("youremailusername", "password")
msg = "\nHello!"
server.sendmail("[email protected]", "[email protected]", msg)

starttls put the SMTP connection in TLS (Transport Layer security)

Upvotes: 1

Related Questions