SMTPAuthenticationError

Ramashish Baranwal ramashish.lists at gmail.com
Wed May 30 08:42:08 EDT 2007


> 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




More information about the Python-list mailing list