Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python login to email server authentication error

I am on a Linux machine. My company has an email exchange server which is already configured. I am using a Python script to try to login to the email server so that I can send an email programmatically. Here is what I have so far -

server = smtplib.SMTP('email-0.abc.com', 25)
server.set_debuglevel(1)
server.ehlo_or_helo_if_needed()    
server.login('abc/johndoe', 'pwd')

However, at the server.login command, I get an error as

raise SMTPException("No suitable authentication method found.")
SMTPException: No suitable authentication method found.

Anyone know what the problem is please?

Thanks

like image 625
Nupur Avatar asked Oct 02 '12 18:10

Nupur


People also ask

How do I fix SMTP authentication error?

SMTP connection can't be established If you have turned on the 2-factor authentication for your email account so you either need to turn it off or generate an app password for your email account. That app password can be used in your SalesHandy account to connect the email account via SMTP method.

How do you fix 535 5.7 8 username and password not accepted?

If getting "Username and Password not accepted" 535 5.7. 8 error, but user name and password work logging onto email via web (with 2-factor authentication), you may need to enable "Access for less secure apps" (allow exceptions to 2-factor authentication) in your email settings.

How do I use SMTP in Python?

To send the mail you use smtpObj to connect to the SMTP server on the local machine and then use the sendmail method along with the message, the from address, and the destination address as parameters (even though the from and to addresses are within the e-mail itself, these aren't always used to route mail).


1 Answers

You might need to switch to STARTTLS authentication. Here's an example that helped me.

How To Send Email In Python Via SMTPLIB

like image 83
JohnMudd Avatar answered Sep 18 '22 17:09

JohnMudd