[Tutor] smtplib with yahoo smtp server

Ewald Ertl ewald.ertl at hartter.com
Wed Feb 1 11:27:22 CET 2006


Hi!



Intercodes wrote:
> Ewald,
> 
>  First off, thanks for stopping by.
> 
>     >The connection via the smtplib.SMTP() could be established.
> 
> 
>  I dont think so. I think it fails before the login().
> 
> ------------------------------------------------------
>>>> ex= smtplib.SMTP('smtp.mail.yahoo.com <http://smtp.mail.yahoo.com>')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.4/smtplib.py", line 241, in __init__
>     (code, msg) = self.connect(host, port)
>   File "/usr/lib/python2.4/smtplib.py", line 289, in connect
>     for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
> socket.gaierror: (-2, 'Name or service not known')
> 
> ------------------------------------------------

Here you get a different Traceback than in the original post.

After digging in smtplib.py here ( Python 2.3.3 )

the call should be socket.getaddrinfo( "smtp.mail.yahoo.com", 25, 0, socket.SOCK_STREAM );

which succeeds here at my installation.

How do you resolve your hostnames ( /etc/nsswitch.conf gives the order of hostname resolution )



>  >>> socket.gethostname()
> 'linux'
> ---------------------------------------------
> 
>>>> socket.gethostbyname(socket.gethostname())
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> socket.gaierror: (-2, 'Name or service not known')
>>>>
> -------------------------------------------------- 

This should resolve your own local hostname!
The socket.gethostbyname() is a call into a shared object of Python and this would use
( So think I ) the standard-Libraries for resolution.

Is "linux" a valid hostname?
Does "ping linux" succeed.

I still think, that this a name resolution error on your host.

HTH Ewald



More information about the Tutor mailing list