Merge branch 'nd/stop-setenv-work-tree' into nd/clear-gitenv-upon-use-of-alias
[gitweb.git] / contrib / hooks / multimail / git_multimail.py
index 7cb2b36cb43da930fbe5baa2cb120676fe7663ae..c06ce7a5158175b684a70e6a148031593a12fb47 100755 (executable)
@@ -1745,14 +1745,20 @@ def __init__(self, envelopesender, smtpserver,
         self.username = smtpuser
         self.password = smtppass
         try:
+            def call(klass, server, timeout):
+                try:
+                    return klass(server, timeout=timeout)
+                except TypeError:
+                    # Old Python versions do not have timeout= argument.
+                    return klass(server)
             if self.security == 'none':
-                self.smtp = smtplib.SMTP(self.smtpserver, timeout=self.smtpservertimeout)
+                self.smtp = call(smtplib.SMTP, self.smtpserver, timeout=self.smtpservertimeout)
             elif self.security == 'ssl':
-                self.smtp = smtplib.SMTP_SSL(self.smtpserver, timeout=self.smtpservertimeout)
+                self.smtp = call(smtplib.SMTP_SSL, self.smtpserver, timeout=self.smtpservertimeout)
             elif self.security == 'tls':
                 if ':' not in self.smtpserver:
                     self.smtpserver += ':587'  # default port for TLS
-                self.smtp = smtplib.SMTP(self.smtpserver, timeout=self.smtpservertimeout)
+                self.smtp = call(smtplib.SMTP, self.smtpserver, timeout=self.smtpservertimeout)
                 self.smtp.ehlo()
                 self.smtp.starttls()
                 self.smtp.ehlo()