473,378 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SMTPAuthenticationError

Hi,

I am trying to send a mail using smtplib. My server requires me to
authenticate, for this I'm using SMTP.login function. However it
fails-
>>server = smtplib.SMTP(host='mail.domain', port=25)
server.login('username', 'password')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/smtplib.py", line 587, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, 'authorization failed
(#5.7.0)')

I am sure that I am giving the correct credentials. The same works in
Thunderbird. Am I missing something here or am I supposed to use some
other library for this?

Thanks in advance,
Ram

May 29 '07 #1
3 12976
Ramashish Baranwal wrote:
Hi,

I am trying to send a mail using smtplib. My server requires me to
authenticate, for this I'm using SMTP.login function. However it
fails-
>>>server = smtplib.SMTP(host='mail.domain', port=25)
server.login('username', 'password')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/smtplib.py", line 587, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, 'authorization failed
(#5.7.0)')

I am sure that I am giving the correct credentials. The same works in
Thunderbird. Am I missing something here or am I supposed to use some
other library for this?

Thanks in advance,
Ram
Are you sure that your SMTP server uses this type of authentication?
Some SMTP servers use POP3 followed by SMTP to authenticate instead.
use telnet to verify, this link might help.

http://www.computerperformance.co.uk...20Auth%20Login

-Larry
May 29 '07 #2
>
I am trying to send a mail using smtplib. My server requires me to
authenticate, for this I'm using SMTP.login function. However it
fails-
>>server = smtplib.SMTP(host='mail.domain', port=25)
server.login('username', 'password')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/smtplib.py", line 587, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, 'authorization failed
(#5.7.0)')
I am sure that I am giving the correct credentials. The same works in
Thunderbird. Am I missing something here or am I supposed to use some
other library for this?
Thanks in advance,
Ram

Are you sure that your SMTP server uses this type of authentication?
Some SMTP servers use POP3 followed by SMTP to authenticate instead.

use telnet to verify, this link might help.

http://www.computerperformance.co.uk...nge2003_SMTP_A...
Hi Larry,

Thanks for the reply. I have worked according to the steps in the link
you provided. From that it seems my server accepts base64 encoded
username and password. I am able to login this way. How to give the
same in smtplib?

Ram

May 29 '07 #3
To help debug this, you may want to try the following.
>
1) Copy smptlib.py into your local directory. On my
box, you can find it here, or import sys; print
sys.path to help find it on your box:

/usr/local/lib/python2.3

2) Go the login() method, add some print statements
there to see what's going on.

I admit to not being an SMTP expert nor fully
understanding the code at first glance, but here is
some code iin smtplib.py that suggests you're close to
getting this working, to the extent that your server
wants base64 encoding:

def encode_cram_md5(challenge, user,
password):
challenge = base64.decodestring(challenge)
response = user + " " +
hmac.HMAC(password, challenge).hexdigest()
return encode_base64(response, eol="")

Hope this helps.
Thanks Steve, that helped a lot. smtplib was trying to a CRAM-MD5 auth
which wasn't working. I don't know why. But when I made it do a LOGIN
auth by changing its preferred_auth list, it worked. Login has its own
preferred list of auth methods which is nice except that not all
servers which advertise a particular method may be capable of handling
that.

It would have been good if there was optionally a way to specify in
login() what method to use. For now, I am simply going to derive SMTP
to form a class that does LOGIN auth.

Ram

May 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Geller | last post by:
Hi, I had been using smptlib to send email via my covad relay previously (several months ago), and it worked fine. Covad requires authentication, and this was accomplished fine with...
5
by: sui | last post by:
this is my code import sys, os, glob, datetime, time import smtplib ## Parameters for SMTP session port=587 SMTPserver= 'smtp.gmail.com' SMTPuser= '...@gmail.com' pw= 'fill in here'...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.