Skip to content

Commit

Permalink
Added support for force_tls flag. Leaving the no_tls flag out right now.
Browse files Browse the repository at this point in the history
  • Loading branch information
zopyx committed Aug 24, 2007
1 parent 080c56b commit ef6c871
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
9 changes: 3 additions & 6 deletions MailHost.py
Expand Up @@ -97,7 +97,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):


def __init__(self, id='', title='', smtp_host='localhost', smtp_port=25,
force_tls=False, no_tls=False,
force_tls=False,
smtp_uid='', smtp_pwd='', smtp_queue=False, smtp_queue_directory='/tmp'):
"""Initialize a new MailHost instance """
self.id = id
Expand All @@ -107,7 +107,6 @@ def __init__(self, id='', title='', smtp_host='localhost', smtp_port=25,
self.smtp_uid = smtp_uid
self.smtp_pwd = smtp_pwd
self.force_tls = force_tls
self.no_tls = no_tls
self.smtp_queue = smtp_queue
self.smtp_queue_directory = smtp_queue_directory

Expand All @@ -120,7 +119,7 @@ def _init(self, smtp_host, smtp_port):
security.declareProtected(change_configuration, 'manage_makeChanges')
def manage_makeChanges(self,title,smtp_host,smtp_port,smtp_uid='',smtp_pwd='',
smtp_queue=False, smtp_queue_directory='/tmp',
force_tls=False, no_tls=False,
force_tls=False,
REQUEST=None):
'make the changes'

Expand All @@ -133,7 +132,6 @@ def manage_makeChanges(self,title,smtp_host,smtp_port,smtp_uid='',smtp_pwd='',
self.smtp_port=smtp_port
self.smtp_uid = smtp_uid
self.smtp_pwd = smtp_pwd
self.no_tls = no_tls
self.force_tls = force_tls
self.smtp_queue = smtp_queue
self.smtp_queue_directory = smtp_queue_directory
Expand Down Expand Up @@ -196,10 +194,9 @@ def simple_send(self, mto, mfrom, subject, body):
def _makeMailer(self):
""" Create a SMTPMailer """
return SMTPMailer(hostname=self.smtp_host,
int(self.smtp_port),
port=int(self.smtp_port),
username=self.smtp_uid or None,
password=self.smtp_pwd or None,
no_tls=self.no_tls,
force_tls=self.force_tls
)

Expand Down
17 changes: 17 additions & 0 deletions dtml/manageMailHost.dtml
Expand Up @@ -76,6 +76,23 @@
<span class="form-help">(optional for SMTP AUTH)</span>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Force TLS
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="force_tls:boolean" value="1"
<dtml-if "force_tls">checked</dtml-if>
</td>
<td>
<span class="form-help">(enforce the use of an encrypted connection
to the SMTP server. Mail delivery fails if the SMTP server
does not support encryption)
</span>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Expand Down

0 comments on commit ef6c871

Please sign in to comment.