[Zope-Checkins] CVS: Zope/lib/python/Products/MailHost - MailHost.py:1.81.4.1

Lennart Regebro regebro at nuxeo.com
Thu Dec 11 15:22:42 EST 2003


Update of /cvs-repository/Zope/lib/python/Products/MailHost
In directory cvs.zope.org:/tmp/cvs-serv27842/lib/python/Products/MailHost

Modified Files:
      Tag: regebro-esmtp_support-branch
	MailHost.py 
Log Message:
Support for ESMTP user+password authorization.


=== Zope/lib/python/Products/MailHost/MailHost.py 1.81 => 1.81.4.1 ===
--- Zope/lib/python/Products/MailHost/MailHost.py:1.81	Tue Nov 18 08:17:05 2003
+++ Zope/lib/python/Products/MailHost/MailHost.py	Thu Dec 11 15:22:09 2003
@@ -49,6 +49,8 @@
     manage_main._setName('manage_main')
     index_html=None
     security = ClassSecurityInfo()
+    smtp_uid='' # Class attributes for smooth upgrades
+    smtp_pwd=''
 
     timeout=1.0
 
@@ -63,12 +65,15 @@
         )
 
 
-    def __init__( self, id='', title='', smtp_host='localhost', smtp_port=25 ):
+    def __init__( self, id='', title='', smtp_host='localhost', smtp_port=25, 
+                  smtp_uid='', smtp_pwd=''):
         """Initialize a new MailHost instance """
         self.id = id
         self.title = title
         self.smtp_host = str( smtp_host )
         self.smtp_port = int(smtp_port)
+        self.smtp_uid = smtp_uid
+        self.smtp_pwd = smtp_pwd
 
 
     # staying for now... (backwards compatibility)
@@ -78,7 +83,7 @@
 
 
     security.declareProtected( 'Change configuration', 'manage_makeChanges' )
-    def manage_makeChanges(self,title,smtp_host,smtp_port, REQUEST=None):
+    def manage_makeChanges(self,title,smtp_host,smtp_port,smtp_uid,smtp_pwd, REQUEST=None):
         'make the changes'
 
         title=str(title)
@@ -88,6 +93,8 @@
         self.title=title
         self.smtp_host=smtp_host
         self.smtp_port=smtp_port
+        self.smtp_uid = smtp_uid
+        self.smtp_pwd = smtp_pwd
         if REQUEST is not None:
             msg = 'MailHost %s updated' % self.id
             return self.manage_main( self
@@ -141,7 +148,9 @@
     security.declarePrivate( '_send' )
     def _send( self, mfrom, mto, messageText ):
         """ Send the message """
-        smtpserver = SMTP( self.smtp_host, int(self.smtp_port) )
+        smtpserver = SMTP(self.smtp_host, int(self.smtp_port) )
+        if self.smtp_uid:
+            smtpserver.login(self.smtp_uid, self.smtp_pwd)
         smtpserver.sendmail( mfrom, mto, messageText )
         smtpserver.quit()
 




More information about the Zope-Checkins mailing list