Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.50 diff -u -r1.50 smtplib.py --- smtplib.py 25 Mar 2002 04:00:38 -0000 1.50 +++ smtplib.py 25 Mar 2002 15:55:13 -0000 @@ -237,9 +237,15 @@ if code != 220: raise SMTPConnectError(code, msg) if local_hostname: - self.local_hostname = local_hostname + self.local_hostname = local_hostname else: - self.local_hostname = socket.getfqdn() + fqdn = socket.getfqdn() + if '.' in fqdn: + self.local_hostname = fqdn + else: + # We can't find an fqdn hostname, so use a domain literal + addr = socket.gethostbyname(socket.gethostname()) + self.local_hostname = '[%s]' % addr def set_debuglevel(self, debuglevel): """Set the debug output level.