summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-10-22 13:09:20 (GMT)
committerGuido van Rossum <guido@python.org>1999-10-22 13:09:20 (GMT)
commitbda10c81d06e36ab9d90f5c5d0d336589347da39 (patch)
tree6780a743b52db0800b23360c1675f6c34d5b7557 /Lib/smtplib.py
parentd6512808f0e5b0953367eeef5adc6a4a7aaaa8c4 (diff)
downloadcpython-bda10c81d06e36ab9d90f5c5d0d336589347da39.zip
cpython-bda10c81d06e36ab9d90f5c5d0d336589347da39.tar.gz
cpython-bda10c81d06e36ab9d90f5c5d0d336589347da39.tar.bz2
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-xLib/smtplib.py12
1 files 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)