smtp: use 465 as default port for SMTPS
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 19 Apr 2013 01:26:23 +0900
changeset 19050 601c1e226889
parent 19049 2e5476980a57
child 19051 55c6ab8163ec
smtp: use 465 as default port for SMTPS Before this patch, port 25 (wellknown port of SMTP) is used as default port, even if "[smtp] tls" is configured as "smtps". This patch uses port 465 (wellknown port of SMTPS) as default port, if "[smtp] tls" is configured as "smtps".
mercurial/help/config.txt
mercurial/mail.py
--- a/mercurial/help/config.txt	Thu Feb 21 21:05:06 2013 +0000
+++ b/mercurial/help/config.txt	Fri Apr 19 01:26:23 2013 +0900
@@ -1046,7 +1046,8 @@
     Host name of mail server, e.g. "mail.example.com".
 
 ``port``
-    Optional. Port to connect to on mail server. Default: 25.
+    Optional. Port to connect to on mail server. Default: 465 (if
+    ``tls`` is smtps) or 25 (otherwise).
 
 ``tls``
     Optional. Method to enable TLS when connecting to mail server: starttls,
--- a/mercurial/mail.py	Thu Feb 21 21:05:06 2013 +0000
+++ b/mercurial/mail.py	Fri Apr 19 01:26:23 2013 +0900
@@ -111,7 +111,11 @@
         s = STARTTLS(sslkwargs, local_hostname=local_hostname)
     else:
         s = smtplib.SMTP(local_hostname=local_hostname)
-    mailport = util.getport(ui.config('smtp', 'port', 25))
+    if smtps:
+        defaultport = 465
+    else:
+        defaultport = 25
+    mailport = util.getport(ui.config('smtp', 'port', defaultport))
     ui.note(_('sending mail: smtp host %s, port %s\n') %
             (mailhost, mailport))
     s.connect(host=mailhost, port=mailport)