Trying to send email using outlook credentials in python

164 Views Asked by At
outlook_server = 'smtp-mail.outlook.com'
outlook_port = 587

# Your email credentials
username = ''
password = ''
# password = 'Alpine1400!'
# Create a connection to the SMTP server using SSL
server = smtplib.SMTP(outlook_server, outlook_port)
server.ehlo()
server.starttls()
server.ehlo()
server.ehlo()
# Log in to your account
server.login(username, password, initial_response_ok=True)

i have attached the error image i m getting this error on server.login line checked the credentials numerous times and i m using app password generated by outlook have tried all the ports my firewall is also off no antivirus running meaning i have exhausted all the google chatgpt solutions still having the same error if anyone can help here

ERROR:

smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful [DX0P273CA0065.AREP273.PROD.OUTLOOK.COM 2023-11-17T14:12:55.892Z 08DBE70BA75BEAD0]')

1

There are 1 best solutions below

2
On

Office 365 no longer allows basic credentials when sending messages through SMTP. You need to use OAuth.