Get authentication error while using 'smtplib'

Mahmood Naderan nt_mahmood at yahoo.com
Sun Aug 22 19:05:56 CEST 2010


Well, login plain did the job:
 
session = smtplib.SMTP(smtpserver)
session.ehlo()
session.esmtp_features["auth"] = "LOGIN PLAIN"if AUTHREQUIRED:
   session.login(smtpuser, smtppass)

 
// Naderan *Mahmood;




________________________________
From: Mahmood Naderan <nt_mahmood at yahoo.com>
To: python mailing list <python-list at python.org>
Sent: Fri, August 20, 2010 6:13:20 PM
Subject: Get authentication error while using 'smtplib'


I have this script to send an email via SMTP:
import smtplib
smtpserver = 'smtp.server.com'
AUTHREQUIRED = 1# if you need to use SMTP AUTH set to 1
smtpuser = "username"# for SMTP AUTH, set SMTP username here
smtppass = "password"# for SMTP AUTH, set SMTP password here
RECIPIENTS ='recipient at server.com'
SENDER = 'sender at server.com'
mssg = open('filename.txt', 'r').read()
session = smtplib.SMTP(smtpserver)
if AUTHREQUIRED:
   session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)
After running the script I get this error:
 
Traceback (most recent call last):
  File "my_mail.py", line 14, in <module>
    session.login(smtpuser, smtppass)
  File "/usr/lib/python2.6/smtplib.py", line 589, in login
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, '5.7.0 Error: authentication failed: 
authentication failure')

However there is no problem with my user/pass because I can login to my mail 
account.

Thanks for any idea. 
// Naderan *Mahmood; 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100822/6f36dc5a/attachment.html>


More information about the Python-list mailing list