[Python-Dev] 2nd thought: fully qualified host names
Peter Schneider-Kamp
nowonder@nowonder.de
Thu, 10 Aug 2000 23:34:38 +0000
Thomas Wouters wrote:
>
> Oh, I forgot to point out: I have some RFC knowledge, but decided not to use
> it in the case of the HELO message ;) I do have a lot of hands-on experience
> with SMTP, and I know for a fact very little MUA that talk SMTP send a FQDN
> in the HELO message. I think that sending the FQDN when we can (like we do,
> now) is a good idea, but I don't see a reason to force the HELO message to
> be a FQDN.
I don't want to force anything. I think it's time for some
code to speak for itself, rather than me trying to
speak for it <0.8 wink>:
def _get_fqdn_hostname(name):
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
This is the same function as the one I checked into
smtplib.py with the exception of executing the try-block
also for names with len(name) != 0.
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter@schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de