On Aug 27, 12:47 pm, [EMAIL PROTECTED] wrote: > On Aug 27, 12:32 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] wrote: > > > Hi all, > > > > I'm having trouble with the socket module resolving a hostname. It > > > seems like this is a system level problem, but I'm not even sure where > > > to start. I can ping the smtp server by name and IP, but when > > > smtp.SMTP("theHost") tries to get the hostname, it keeps giving me the > > > following error: > > > > File "bin/program.py", line 123, in notify > > > smtp = smtplib.SMTP("theHost") > > > > File "/usr/lib/python2.4/smtplib.py", line 255, in __init__ > > > addr = socket.gethostbyname(socket.gethostname()) > > > > gaierror: (-2, 'Name or service not known') > > > > I tried changing to a different smtp server, using an ip instead of a > > > host name. I could ping both boxes by name oor IP. > > > > any ideas? > > > > ~Sean > > > The specific error shown is a DNS resolution problem. Based on the > > URL "theHost" smtplib can't resolve to an IP address (which is what > > socket.gethostbyname does). You don't say what happened when you changed > > to ip, > > but I suspect it is a different error or some other problem. Maybe a > > firewall > > issue (port 25 not open?), but I'm just guessing. > > > -Larry > > Changing it to IP gives me the same exact error... > > File "bin/prgram.py", line 123, in notify > smtp = smtplib.SMTP("XXX.XXX.XXX.XXX") > > File "/usr/lib/python2.4/smtplib.py", line 255, in __init__ > addr = socket.gethostbyname(socket.gethostname()) > > gaierror: (-2, 'Name or service not known') > > Looks like the smtp port is closed on the client machine...doh Should > have gotten to that! > > Thank you. > > ~Sean
I take it back, that wasn't the solution. I got it to work by haacking smtplib with a static host instead of the socket.gethostbyname(socket.gethostname()) call...but if I leave that in there I might get shot one day. What could cause the shell to be able to resolve the addresses properly, but not python? nnsswitch.conf ? I don't know enough about what's going on in the background. Any other ideas? Or should I try this on a unix board? ~Sean -- http://mail.python.org/mailman/listinfo/python-list