mercurial/mail.py
changeset 39031 2cf3bd4ae55e
parent 39028 713126389ef2
child 39037 ede768cfe83e
equal deleted inserted replaced
39030:1eb779a86c4e 39031:2cf3bd4ae55e
   150     return send
   150     return send
   151 
   151 
   152 def _sendmail(ui, sender, recipients, msg):
   152 def _sendmail(ui, sender, recipients, msg):
   153     '''send mail using sendmail.'''
   153     '''send mail using sendmail.'''
   154     program = ui.config('email', 'method')
   154     program = ui.config('email', 'method')
   155     cmdline = '%s -f %s %s' % (program, stringutil.email(sender),
   155     stremail = lambda x: stringutil.email(encoding.strtolocal(x))
   156                                ' '.join(map(stringutil.email, recipients)))
   156     cmdline = '%s -f %s %s' % (program, stremail(sender),
       
   157                                ' '.join(map(stremail, recipients)))
   157     ui.note(_('sending mail: %s\n') % cmdline)
   158     ui.note(_('sending mail: %s\n') % cmdline)
   158     fp = procutil.popen(cmdline, 'wb')
   159     fp = procutil.popen(cmdline, 'wb')
   159     fp.write(util.tonativeeol(msg))
   160     fp.write(util.tonativeeol(msg))
   160     ret = fp.close()
   161     ret = fp.close()
   161     if ret:
   162     if ret:
   167     '''write mails to mbox'''
   168     '''write mails to mbox'''
   168     fp = open(mbox, 'ab+')
   169     fp = open(mbox, 'ab+')
   169     # Should be time.asctime(), but Windows prints 2-characters day
   170     # Should be time.asctime(), but Windows prints 2-characters day
   170     # of month instead of one. Make them print the same thing.
   171     # of month instead of one. Make them print the same thing.
   171     date = time.strftime(r'%a %b %d %H:%M:%S %Y', time.localtime())
   172     date = time.strftime(r'%a %b %d %H:%M:%S %Y', time.localtime())
   172     fp.write('From %s %s\n' % (sender, date))
   173     fp.write('From %s %s\n' % (encoding.strtolocal(sender),
       
   174                                encoding.strtolocal(date)))
   173     fp.write(msg)
   175     fp.write(msg)
   174     fp.write('\n\n')
   176     fp.write('\n\n')
   175     fp.close()
   177     fp.close()
   176 
   178 
   177 def connect(ui, mbox=None):
   179 def connect(ui, mbox=None):