diff options
author | Guido van Rossum <guido@python.org> | 1999-10-22 13:09:20 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-10-22 13:09:20 +0000 |
commit | bc6c9b8865d59a9edcafa7041a5e9e7195ed2ebb (patch) | |
tree | 5b283020098cf08453174f67500a918b4d84ecbe /Lib/smtplib.py | |
parent | 64fe92d459adaef50ce72cfb8ea7f4e7d440c467 (diff) | |
download | cpython-bc6c9b8865d59a9edcafa7041a5e9e7195ed2ebb.tar.gz |
In helo() and ehlo(), Don't fail when gethostbyaddr() fails -- just
keep whatever gethostname() returns. After a suggestion by Doug Wyatt.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-x | Lib/smtplib.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 8cca5908e0..6a3de7ff0c 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) |