mercurial/mail.py
changeset 6548 962eb403165b
parent 5975 75d9fe70c654
child 7114 30e49d54c537
equal deleted inserted replaced
6533:65f1b97484be 6548:962eb403165b
     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, util, socket
     9 import os, smtplib, socket
       
    10 import util
    10 
    11 
    11 def _smtp(ui):
    12 def _smtp(ui):
    12     '''build an smtp connection and return a function to send mail'''
    13     '''build an smtp connection and return a function to send mail'''
    13     local_hostname = ui.config('smtp', 'local_hostname')
    14     local_hostname = ui.config('smtp', 'local_hostname')
    14     s = smtplib.SMTP(local_hostname=local_hostname)
    15     s = smtplib.SMTP(local_hostname=local_hostname)
    51     '''send mail using sendmail.'''
    52     '''send mail using sendmail.'''
    52     program = ui.config('email', 'method')
    53     program = ui.config('email', 'method')
    53     cmdline = '%s -f %s %s' % (program, util.email(sender),
    54     cmdline = '%s -f %s %s' % (program, util.email(sender),
    54                                ' '.join(map(util.email, recipients)))
    55                                ' '.join(map(util.email, recipients)))
    55     ui.note(_('sending mail: %s\n') % cmdline)
    56     ui.note(_('sending mail: %s\n') % cmdline)
    56     fp = os.popen(cmdline, 'w')
    57     fp = util.popen(cmdline, 'w')
    57     fp.write(msg)
    58     fp.write(msg)
    58     ret = fp.close()
    59     ret = fp.close()
    59     if ret:
    60     if ret:
    60         raise util.Abort('%s %s' % (
    61         raise util.Abort('%s %s' % (
    61             os.path.basename(program.split(None, 1)[0]),
    62             os.path.basename(program.split(None, 1)[0]),