From bda10c81d06e36ab9d90f5c5d0d336589347da39 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 22 Oct 1999 13:09:20 +0000 Subject: In helo() and ehlo(), Don't fail when gethostbyaddr() fails -- just keep whatever gethostname() returns. After a suggestion by Doug Wyatt. --- Lib/smtplib.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 8cca590..6a3de7f 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) -- cgit v0.12