Commit 555014ea authored by Andreas Jung's avatar Andreas Jung

support for no_tls, force_tls options

parent 1c736329
...@@ -96,8 +96,9 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -96,8 +96,9 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
) )
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='', smtp_queue=False, smtp_queue_directory='/tmp'): force_tls=False, no_tls=False,
smtp_uid='', smtp_pwd='', smtp_queue=False, smtp_queue_directory='/tmp'):
"""Initialize a new MailHost instance """ """Initialize a new MailHost instance """
self.id = id self.id = id
self.title = title self.title = title
...@@ -105,6 +106,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -105,6 +106,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
self.smtp_port = int(smtp_port) self.smtp_port = int(smtp_port)
self.smtp_uid = smtp_uid self.smtp_uid = smtp_uid
self.smtp_pwd = smtp_pwd self.smtp_pwd = smtp_pwd
self.force_tls = force_tls
self.no_tls = no_tls
self.smtp_queue = smtp_queue self.smtp_queue = smtp_queue
self.smtp_queue_directory = smtp_queue_directory self.smtp_queue_directory = smtp_queue_directory
...@@ -117,6 +120,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -117,6 +120,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
security.declareProtected(change_configuration, 'manage_makeChanges') security.declareProtected(change_configuration, 'manage_makeChanges')
def manage_makeChanges(self,title,smtp_host,smtp_port,smtp_uid='',smtp_pwd='', def manage_makeChanges(self,title,smtp_host,smtp_port,smtp_uid='',smtp_pwd='',
smtp_queue=False, smtp_queue_directory='/tmp', smtp_queue=False, smtp_queue_directory='/tmp',
force_tls=False, no_tls=False,
REQUEST=None): REQUEST=None):
'make the changes' 'make the changes'
...@@ -129,6 +133,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -129,6 +133,8 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
self.smtp_port=smtp_port self.smtp_port=smtp_port
self.smtp_uid = smtp_uid self.smtp_uid = smtp_uid
self.smtp_pwd = smtp_pwd self.smtp_pwd = smtp_pwd
self.no_tls = no_tls
self.force_tls = force_tls
self.smtp_queue = smtp_queue self.smtp_queue = smtp_queue
self.smtp_queue_directory = smtp_queue_directory self.smtp_queue_directory = smtp_queue_directory
...@@ -189,10 +195,12 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -189,10 +195,12 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
def _makeMailer(self): def _makeMailer(self):
""" Create a SMTPMailer """ """ Create a SMTPMailer """
return SMTPMailer(self.smtp_host, return SMTPMailer(hostname=self.smtp_host,
int(self.smtp_port), int(self.smtp_port),
self.smtp_uid or None, username=self.smtp_uid or None,
self.smtp_pwd or None password=self.smtp_pwd or None,
no_tls=self.no_tls,
force_tls=self.force_tls
) )
@synchronized(lock) @synchronized(lock)
...@@ -205,7 +213,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -205,7 +213,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
thread.stop() thread.stop()
while thread.isAlive(): while thread.isAlive():
# wait until thread is really dead # wait until thread is really dead
time.sleep(0.1) time.sleep(0.3)
del queue_threads[path] del queue_threads[path]
LOG.info('Thread for %s stopped' % path) LOG.info('Thread for %s stopped' % path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment