comparison mercurial/mail.py @ 12076:49463314c24f

mail/hgweb: support service names for ports (issue2350) This adds util.getport(port) which tries to parse port as an int, and failing that, looks it up using socket.getservbyname(). Thus, the following will work: [smtp] port = submission [web] port = http This does not apply to ports in URLs used in clone, pull, etc.
author Brodie Rao <brodie@bitheap.org>
date Sat, 28 Aug 2010 12:31:07 -0400
parents 594b98846ce1
children 339bd18c772f
comparison
equal deleted inserted replaced
12075:f585c9bb85c1 12076:49463314c24f
35 local_hostname = ui.config('smtp', 'local_hostname') 35 local_hostname = ui.config('smtp', 'local_hostname')
36 s = smtplib.SMTP(local_hostname=local_hostname) 36 s = smtplib.SMTP(local_hostname=local_hostname)
37 mailhost = ui.config('smtp', 'host') 37 mailhost = ui.config('smtp', 'host')
38 if not mailhost: 38 if not mailhost:
39 raise util.Abort(_('no [smtp]host in hgrc - cannot send mail')) 39 raise util.Abort(_('no [smtp]host in hgrc - cannot send mail'))
40 mailport = int(ui.config('smtp', 'port', 25)) 40 mailport = util.getport(ui.config('smtp', 'port', 25))
41 ui.note(_('sending mail: smtp host %s, port %s\n') % 41 ui.note(_('sending mail: smtp host %s, port %s\n') %
42 (mailhost, mailport)) 42 (mailhost, mailport))
43 s.connect(host=mailhost, port=mailport) 43 s.connect(host=mailhost, port=mailport)
44 if ui.configbool('smtp', 'tls'): 44 if ui.configbool('smtp', 'tls'):
45 if not hasattr(socket, 'ssl'): 45 if not hasattr(socket, 'ssl'):