<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><SPAN lang=EN>
<P><FONT size=3 face="tahoma, new york, times, serif">Well, login plain did the job:</FONT></P>
<P> </P>
<P>session = smtplib.SMTP(smtpserver)</P>
<P><STRONG>session.ehlo()</STRONG></P>
<P><STRONG>session.esmtp_features["auth"] = "LOGIN PLAIN"<FONT face="Courier New"><FONT face="Courier New"></P></FONT></FONT></STRONG><FONT size=1>
<P><FONT size=2>if AUTHREQUIRED:</FONT></P>
<P><FONT size=2> session.login(smtpuser, smtppass)</FONT></P></FONT></SPAN>
<DIV></DIV>
<DIV><BR> </DIV>
<DIV>
<DIV><FONT style="BACKGROUND-COLOR: #ffffff" color=#0080ff size=2 face="arial, helvetica, sans-serif"><STRONG>// Naderan *Mahmood;</STRONG></FONT></DIV></DIV>
<DIV><BR></DIV>
<DIV style="FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif; FONT-SIZE: 10pt"><BR>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Mahmood Naderan <nt_mahmood@yahoo.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> python mailing list <python-list@python.org><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Fri, August 20, 2010 6:13:20 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Get authentication error while using 'smtplib'<BR></FONT><BR>
<DIV style="FONT-FAMILY: tahoma, new york, times, serif; COLOR: #000000; FONT-SIZE: 12pt">
<DIV></DIV>
<DIV>I have this script to send an email via SMTP:</DIV>
<DIV> </DIV><SPAN lang=EN>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">import smtplib</FONT></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">smtpserver = '<A href="http://smtp.server.com/" target=_blank>smtp.server.com</A></FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">'</FONT></FONT></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">AUTHREQUIRED = </FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">1</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif"> # if you need to use SMTP AUTH set to 1</FONT></FONT></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">smtpuser = </FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">"username"</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif"> # for SMTP AUTH, set SMTP username here</FONT></FONT></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">smtppass = </FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">"password"</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif"> # for SMTP AUTH, set SMTP password here</FONT></FONT></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">RECIPIENTS =</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif"> <A href="mailto:'recipient@server.com'" rel=nofollow target=_blank ymailto="mailto:'recipient@server.com'">'recipient@server.com</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">'</FONT></FONT></A></P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">SENDER = </FONT><A href="mailto:'sender@server.com'" rel=nofollow target=_blank ymailto="mailto:'sender@server.com'"><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">'sender@server.com'</FONT></A></P>
<P><FONT size=2><FONT face="Courier New, courier, monaco, monospace, sans-serif">mssg = open(</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">'filename</FONT><FONT face="Courier New, courier, monaco, monospace, sans-serif">.txt', 'r').read()</FONT></FONT></P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">session = smtplib.SMTP(smtpserver)</FONT></P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">if AUTHREQUIRED:</FONT></P>
<P><FONT size=1><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif"> session.login(smtpuser, smtppass)</FONT></P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)</FONT></P>
<P></FONT></SPAN> </P>
<P>After running the script I get this error:</P>
<P> </P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif">Traceback (most recent call last):<BR> File "<A href="http://my_mail.py/" target=_blank>my_mail.py</A>", line 14, in <module><BR> session.login(smtpuser, smtppass)<BR> File "/usr/lib/python2.6/smtplib.py", line 589, in login<BR> raise SMTPAuthenticationError(code, resp)<BR>smtplib.SMTPAuthenticationError: (535, '5.7.0 Error: authentication failed: authentication failure')<BR></FONT></P>
<DIV>However there is no problem with my user/pass because I can login to my mail account.</DIV>
<DIV> </DIV>
<DIV>Thanks for any idea. </DIV>
<DIV>
<DIV><FONT style="BACKGROUND-COLOR: #ffffff" color=#0080ff size=2 face="arial, helvetica, sans-serif"><STRONG>// Naderan *Mahmood;</STRONG></FONT></DIV></DIV>
<DIV></DIV></DIV><BR></DIV></DIV></div><br></body></html>