0

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("you@gmail.com", "target@example.com", 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?

1 Answers1

1

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("you@gmail.com", "target@example.com", msg)

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

Hackaholic
  • 19,069
  • 5
  • 54
  • 72