summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-11-07 01:10:13 +0000
committerZac Medico <zmedico@gentoo.org>2009-11-07 01:10:13 +0000
commitf329f7494d17dd5e53ea50a71cc9239c3f054ed7 (patch)
treeca7044256106789de2444576bd526602949632f0
parentInside depgraph._complete_graph(), only pull in deps for the relevant root (diff)
downloadportage-multirepo-f329f7494d17dd5e53ea50a71cc9239c3f054ed7.tar.gz
portage-multirepo-f329f7494d17dd5e53ea50a71cc9239c3f054ed7.tar.bz2
portage-multirepo-f329f7494d17dd5e53ea50a71cc9239c3f054ed7.zip
Bug #291331 - Make send_mail() encode the unicode message as bytes before
passing it to smtplib.SMTP.sendmail(), in order to avoid a UnicodeEncodeError which SMTP.send() tries to encode the message a plain ascii. (trunk r14776) svn path=/main/branches/2.1.7/; revision=14789
-rw-r--r--pym/portage/mail.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 040cd113..9a69f960 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -127,7 +127,9 @@ def send_mail(mysettings, message):
myconn = smtplib.SMTP(mymailhost, mymailport)
if mymailuser != "" and mymailpasswd != "":
myconn.login(mymailuser, mymailpasswd)
- myconn.sendmail(myfrom, myrecipient, message.as_string())
+ msg = _unicode_encode(message.as_string(),
+ encoding=_encodings['content'], errors='backslashreplace')
+ myconn.sendmail(myfrom, myrecipient, msg)
myconn.quit()
except smtplib.SMTPException as e:
raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))