Get authentication error while using 'smtplib'

Mahmood Naderan nt_mahmood at yahoo.com
Fri Aug 20 09:43:20 EDT 2010


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/20100820/c0ad2554/attachment.html>


More information about the Python-list mailing list