[I'm not subscribed to the list, please CC me.]

Hi,

I've discussed this patch with Daniel Shahaf in the users mailing list.

This patch makes it possible to use e.g. Gmail's SMTP to send post-commit messages (using SSL).

Can it be applied?

Thanks.

Best regards,
--
João M. S. Silva
[[[
   Fixes issue discussed in the mailing list: mailer.py cannot use SMTP SSL.

   * tools/hook-scripts/mailer/mailer.conf.example (general)
     added option to use SSL with SMTP
   * tools/hook-scripts/mailer/mailer.py (SMTPOutput):
     checks SSL option for SMTP and acts accordingly
]]]
Index: tools/hook-scripts/mailer/mailer.conf.example
===================================================================
--- tools/hook-scripts/mailer/mailer.conf.example	(revision 1775757)
+++ tools/hook-scripts/mailer/mailer.conf.example	(working copy)
@@ -27,6 +27,10 @@
 #smtp_username = example
 #smtp_password = example
 
+# This option specifies whether to use SSL from the beginning of the SMTP
+# connection.
+#smtp_ssl = yes
+
 # --------------------------------------------------------------------------
 
 #
Index: tools/hook-scripts/mailer/mailer.py
===================================================================
--- tools/hook-scripts/mailer/mailer.py	(revision 1775757)
+++ tools/hook-scripts/mailer/mailer.py	(working copy)
@@ -291,7 +291,10 @@ class SMTPOutput(MailedOutput):
     self.write(self.mail_headers(group, params))
 
   def finish(self):
-    server = smtplib.SMTP(self.cfg.general.smtp_hostname)
+    if self.cfg.is_set('general.smtp_ssl') and self.cfg.general.smtp_ssl.lower() == 'yes':
+      server = smtplib.SMTP_SSL(self.cfg.general.smtp_hostname)
+    else:
+      server = smtplib.SMTP(self.cfg.general.smtp_hostname)
     if self.cfg.is_set('general.smtp_username'):
       server.login(self.cfg.general.smtp_username,
                    self.cfg.general.smtp_password)

Reply via email to