From: Guido van Rossum Date: Fri, 22 Oct 1999 13:09:20 +0000 (+0000) Subject: In helo() and ehlo(), Don't fail when gethostbyaddr() fails -- just X-Git-Tag: v1.6a1~805 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bda10c81d06e36ab9d90f5c5d0d336589347da39;p=thirdparty%2FPython%2Fcpython.git In helo() and ehlo(), Don't fail when gethostbyaddr() fails -- just keep whatever gethostname() returns. After a suggestion by Doug Wyatt. --- diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 8cca5908e0e7..6a3de7ff0c99 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -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)