diff options
author | Fred Drake <fdrake@acm.org> | 2000-08-16 14:26:22 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-08-16 14:26:22 (GMT) |
commit | 0ebc1c695266a2031572f767e9b446aa50c831c2 (patch) | |
tree | 8616fdde7912ea95d9f26f6358193b7312ec8202 | |
parent | 5772c86816c843f7d431307632ed607a81931dd1 (diff) | |
download | cpython-0ebc1c695266a2031572f767e9b446aa50c831c2.zip cpython-0ebc1c695266a2031572f767e9b446aa50c831c2.tar.gz cpython-0ebc1c695266a2031572f767e9b446aa50c831c2.tar.bz2 |
Use socket.getfqdn() instead of defining make_fqdn().
-rwxr-xr-x | Lib/smtplib.py | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index f00f30b..beda161 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -133,31 +133,6 @@ def quotedata(data): return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)) -def make_fqdn(name = ''): - """Get fully qualified domain name from name. - - An empty argument is interpreted as meaning the local host. - - First the hostname returned by socket.gethostbyaddr() - is checked, then possibly existing aliases. In case - no FQDN is available, hostname is returned. - """ - name = string.strip(name) - if len(name) == 0: - name = socket.gethostname() - try: - hostname, aliases, ipaddrs = socket.gethostbyaddr(name) - except socket.error: - pass - else: - aliases.insert(0, hostname) - for name in aliases: - if '.' in name: - break - else: - name = hostname - return name - class SMTP: """This class manages a connection to an SMTP or ESMTP server. @@ -317,7 +292,7 @@ class SMTP: if name: self.putcmd("helo", name) else: - self.putcmd("helo", make_fqdn()) + self.putcmd("helo", socket.getfqdn()) (code,msg)=self.getreply() self.helo_resp=msg return (code,msg) @@ -330,7 +305,7 @@ class SMTP: if name: self.putcmd("ehlo", name) else: - self.putcmd("ehlo", make_fqdn()) + self.putcmd("ehlo", socket.getfqdn()) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if |