# HG changeset patch # User FUJIWARA Katsunori # Date 2013-04-18 16:26:23 # Node ID 601c1e226889d41bd166ad0829f103577362b2b6 # Parent 2e5476980a57657e7ed252c56b62a289031530ca 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 --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1046,7 +1046,8 @@ Configuration for extensions that need t 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 --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -111,7 +111,11 @@ def _smtp(ui): 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)