Tutorial Example

Fix smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server – Python SMTP Tutorial

I test a python program to send an email to others by outlook email and i encouter an error:

smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server

The problem code is:

smtpObj = smtplib.SMTP(smtpHost, smtpPort)
smtpObj.login(sender,password)

How to fix this error?

The correct code is:

smtpObj = smtplib.SMTP(smtpHost, smtpPort)
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.ehlo()    
smtpObj.login(sender,password)

So this code works.