In helo() and ehlo(), Don't fail when gethostbyaddr() fails -- just

keep whatever gethostname() returns.  After a suggestion by Doug Wyatt.
This commit is contained in:
Guido van Rossum 1999-10-22 13:09:20 +00:00
parent d6512808f0
commit bda10c81d0
1 changed files with 10 additions and 2 deletions

View File

@ -290,7 +290,11 @@ class SMTP:
"""
name=string.strip(name)
if len(name)==0:
name=socket.gethostbyaddr(socket.gethostname())[0]
name = socket.gethostname()
try:
name = socket.gethostbyaddr(name)[0]
except socket.error:
pass
self.putcmd("helo",name)
(code,msg)=self.getreply()
self.helo_resp=msg
@ -303,7 +307,11 @@ class SMTP:
"""
name=string.strip(name)
if len(name)==0:
name=socket.gethostbyaddr(socket.gethostname())[0]
name = socket.gethostname()
try:
name = socket.gethostbyaddr(name)[0]
except socket.error:
pass
self.putcmd("ehlo",name)
(code,msg)=self.getreply()
# According to RFC1869 some (badly written)