'When I try to use smtplib to send emails, I get an error

from email import message
import smtplib
sender_email = "[email protected]"
rec_email = "[email protected]"

password = "example"
message1 = "test"

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

server.starttls

server.login(sender_email, password)
server.sendmail(sender_email, rec_email, message)

when I do this I get the error

smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.

Does anyone know a solution to this



Solution 1:[1]

Try 456 port instead

import smtplib

sender_email = "[email protected]" 
rec_email = "[email protected]"
password = "password" 
message1 = "test" 
    

server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(sender_email, password)
server.sendmail(sender_email, rec_email, message1)
server.quit()

    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Islam hamdi