[Pythonmac-SIG] problems with smtplib?
Doug Wyatt
doug@sonosphere.com
Thu, 21 Oct 1999 17:44:56 -0400
At 21:37 +0200 10/21/99, Just van Rossum wrote:
> At 3:02 PM -0400 10/21/99, chris mann wrote:
>>I'm having problems with the smtplib module on Mac.
>>
>>if I run the following code on windows or linux it works fine, but fails on
>>mac:
>>import smtplib
>>s = smtplib.SMTP('smtp.myhost.com')
>>s.helo()
>>
>>i get the following error:
>>Traceback (innermost last):
>> File "<input>", line 1, in ?
>> File "Dev:Scripting:Python 1.5.2c1:Lib:smtplib.py", line 290, in helo
>> name=socket.gethostbyaddr(socket.gethostname())[0]
>>error: host not found
>>
>>any ideas why this is only failing on Mac?
>
> Works for me. Can it be your network setup? Firewall?
> Can you see which of the two socket calls fail?
I have the same problem.
>>> socket.gethostname()
'10.9.8.81'
>>> socket.gethostbyaddr(socket.gethostname())
Traceback (innermost last):
File "<input>", line 1, in ?
error: host not found
My machine does not have a name known to the outside world because,
indeed, I am behind an IP masquerading firewall.
So I changed smtplib.ehlo() as follows:
name = socket.gethostname()
try:
name = socket.gethostbyaddr(name)[0]
except:
pass
Sorry, I should have posted this fix when I made it.
Doug
--
Doug Wyatt doug@sonosphere.com
http://www.sonosphere.com/