comparison mercurial/mail.py @ 5975:75d9fe70c654

templater: move email function to util
author Matt Mackall <mpm@selenic.com>
date Thu, 31 Jan 2008 14:44:19 -0600
parents ea77f6f77514
children 962eb403165b
comparison
equal deleted inserted replaced
5974:bed929082b58 5975:75d9fe70c654
4 # 4 #
5 # This software may be used and distributed according to the terms 5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 from i18n import _ 8 from i18n import _
9 import os, smtplib, templater, util, socket 9 import os, smtplib, util, socket
10 10
11 def _smtp(ui): 11 def _smtp(ui):
12 '''build an smtp connection and return a function to send mail''' 12 '''build an smtp connection and return a function to send mail'''
13 local_hostname = ui.config('smtp', 'local_hostname') 13 local_hostname = ui.config('smtp', 'local_hostname')
14 s = smtplib.SMTP(local_hostname=local_hostname) 14 s = smtplib.SMTP(local_hostname=local_hostname)
48 return send 48 return send
49 49
50 def _sendmail(ui, sender, recipients, msg): 50 def _sendmail(ui, sender, recipients, msg):
51 '''send mail using sendmail.''' 51 '''send mail using sendmail.'''
52 program = ui.config('email', 'method') 52 program = ui.config('email', 'method')
53 cmdline = '%s -f %s %s' % (program, templater.email(sender), 53 cmdline = '%s -f %s %s' % (program, util.email(sender),
54 ' '.join(map(templater.email, recipients))) 54 ' '.join(map(util.email, recipients)))
55 ui.note(_('sending mail: %s\n') % cmdline) 55 ui.note(_('sending mail: %s\n') % cmdline)
56 fp = os.popen(cmdline, 'w') 56 fp = os.popen(cmdline, 'w')
57 fp.write(msg) 57 fp.write(msg)
58 ret = fp.close() 58 ret = fp.close()
59 if ret: 59 if ret: