Mailing List Archive

CVS: python/dist/src/Lib smtplib.py,1.50,1.51
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv9439/Lib

Modified Files:
smtplib.py
Log Message:
__init__(): We'll try to be more RFC 2821 compliant by providing for a
better local_hostname default. According to RFC 2821, it is
recommended that the fqdn hostname be provided in the EHLO/HELO verb
and if that can't be calculated, to use a domain literal.

The rationale for this change is documented in SF patch #497736 which
also had privacy concerns about leaking the fqdn in the EHLO/HELO. We
decided this wasn't a big concern because no user data is leaked, and
the IP will always be leaked. The local_hostname argument is provided
for those clients that are super paranoid.

Using localhost.localdomain may break some strict smtp servers so we
decided against using it as the default.


Index: smtplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** smtplib.py 25 Mar 2002 04:00:38 -0000 1.50
--- smtplib.py 26 Mar 2002 20:27:35 -0000 1.51
***************
*** 238,244 ****
raise SMTPConnectError(code, msg)
if local_hostname:
! self.local_hostname = local_hostname
else:
! self.local_hostname = socket.getfqdn()

def set_debuglevel(self, debuglevel):
--- 238,253 ----
raise SMTPConnectError(code, msg)
if local_hostname:
! self.local_hostname = local_hostname
else:
! # RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and
! # if that can't be calculated, that we should use a domain literal
! # instead (essentially an encoded IP address like [A.B.C.D]).
! 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):