[Python-checkins] CVS: python/dist/src/Lib smtplib.py,1.48,1.49

Neil Schemenauer nascheme@users.sourceforge.net
Sun, 24 Mar 2002 07:30:42 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv5877/Lib

Modified Files:
	smtplib.py 
Log Message:
Add local_hostname option to SMTP.__init__.  If supplied, it is used
as the fully qualified local hostname.


Index: smtplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** smtplib.py	24 Feb 2002 15:07:24 -0000	1.48
--- smtplib.py	24 Mar 2002 15:30:40 -0000	1.49
***************
*** 221,225 ****
      does_esmtp = 0
  
!     def __init__(self, host = '', port = 0):
          """Initialize a new instance.
  
--- 221,225 ----
      does_esmtp = 0
  
!     def __init__(self, host = '', port = 0, local_hostname = None):
          """Initialize a new instance.
  
***************
*** 227,231 ****
          connect.  If specified, `port' specifies the port to which to connect.
          By default, smtplib.SMTP_PORT is used.  An SMTPConnectError is raised
!         if the specified `host' doesn't respond correctly.
  
          """
--- 227,233 ----
          connect.  If specified, `port' specifies the port to which to connect.
          By default, smtplib.SMTP_PORT is used.  An SMTPConnectError is raised
!         if the specified `host' doesn't respond correctly.  If specified,
! 	`local_hostname` is used as the FQDN of the local host.  By default,
! 	the local hostname is found using gethostbyname().
  
          """
***************
*** 235,238 ****
--- 237,244 ----
              if code != 220:
                  raise SMTPConnectError(code, msg)
+         if local_hostname:
+                 self.local_hostname = local_hostname
+         else:
+                 self.local_hostname = socket.getfqdn()
  
      def set_debuglevel(self, debuglevel):
***************
*** 357,364 ****
          host.
          """
!         if name:
!             self.putcmd("helo", name)
!         else:
!             self.putcmd("helo", socket.getfqdn())
          (code,msg)=self.getreply()
          self.helo_resp=msg
--- 363,367 ----
          host.
          """
!         self.putcmd("helo", name or self.local_hostname)
          (code,msg)=self.getreply()
          self.helo_resp=msg
***************
*** 371,378 ****
          """
          self.esmtp_features = {}
!         if name:
!             self.putcmd("ehlo", name)
!         else:
!             self.putcmd("ehlo", socket.getfqdn())
          (code,msg)=self.getreply()
          # According to RFC1869 some (badly written)
--- 374,378 ----
          """
          self.esmtp_features = {}
!         self.putcmd("ehlo", name or self.local_hostname)
          (code,msg)=self.getreply()
          # According to RFC1869 some (badly written)