From patchwork Thu Apr 18 17:08:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: smtp: use 465 as default port for SMTPS From: Katsunori FUJIWARA X-Patchwork-Id: 1428 Message-Id: To: mercurial-devel@selenic.com Date: Fri, 19 Apr 2013 02:08:47 +0900 # HG changeset patch # User FUJIWARA Katsunori # Date 1366302383 -32400 # Fri Apr 19 01:26:23 2013 +0900 # Node ID fa1246e1b7453276ca71fb4349e4fac5a2473dff # Parent 7d31f2e42a8afb54c8fae87e8e3e29a63578aea4 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". diff -r 7d31f2e42a8afb54c8fae87e8e3e29a63578aea4 -r fa1246e1b7453276ca71fb4349e4fac5a2473dff mercurial/help/config.txt --- a/mercurial/help/config.txt Mon Apr 15 18:57:04 2013 -0300 +++ 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, diff -r 7d31f2e42a8afb54c8fae87e8e3e29a63578aea4 -r fa1246e1b7453276ca71fb4349e4fac5a2473dff mercurial/mail.py --- a/mercurial/mail.py Mon Apr 15 18:57:04 2013 -0300 +++ 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)