Get authentication error while using 'smtplib'

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

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

// Naderan *Mahmood;

From: Mahmood Naderan <nt_mahmood at>
To: python mailing list <python-list at>
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 = ''
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'
SENDER = 'sender at'
mssg = open('filename.txt', 'r').read()
session = smtplib.SMTP(smtpserver)
   session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)
After running the script I get this error:
Traceback (most recent call last):
  File "", line 14, in <module>
    session.login(smtpuser, smtppass)
  File "/usr/lib/python2.6/", 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 

Thanks for any idea. 
// Naderan *Mahmood; 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list