##// END OF EJS Templates
mail: properly handle email addresses typically being unicodes...
Augie Fackler -
r39066:2cf3bd4a default
parent child Browse files
Show More
@@ -152,8 +152,9 b' def _smtp(ui):'
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))
@@ -169,7 +170,8 b' def _mbox(mbox, sender, recipients, msg)'
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()
General Comments 0
You need to be logged in to leave comments. Login now