diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-11-16 00:30:08 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-11-16 00:30:08 +0000 |
commit | b3df33c444d72a1238e9dc0b2c548a4a67ce92f6 (patch) | |
tree | a7934e5df4679027bd4fcb72e8b70c2b507bd641 | |
parent | da35f20d752830b90630c2e41672b0861fec5b3b (diff) | |
download | portage-b3df33c444d72a1238e9dc0b2c548a4a67ce92f6.tar.gz portage-b3df33c444d72a1238e9dc0b2c548a4a67ce92f6.tar.bz2 portage-b3df33c444d72a1238e9dc0b2c548a4a67ce92f6.zip |
Bug #292528 - Specify UTF-8 in the MIMEText constructor arguments, in order
to avoid conversiont to ascii and subsequent UnicodeEncodeError when sending
mail. The idea comes from here: http://bugs.python.org/issue4403#msg76425.
(trunk r14806)
svn path=/main/branches/2.1.7/; revision=14829
-rw-r--r-- | pym/portage/mail.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pym/portage/mail.py b/pym/portage/mail.py index 9a69f9604..64774cdac 100644 --- a/pym/portage/mail.py +++ b/pym/portage/mail.py @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -from email.mime.text import MIMEText as TextMessage +from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart as MultipartMessage from email.mime.base import MIMEBase as BaseMessage from email.header import Header @@ -21,6 +21,9 @@ import portage if sys.hexversion >= 0x3000000: basestring = str +def TextMessage(_text): + return MIMEText(_text, _charset="UTF-8") + def create_message(sender, recipient, subject, body, attachments=None): if sys.hexversion < 0x3000000: @@ -127,9 +130,7 @@ def send_mail(mysettings, message): myconn = smtplib.SMTP(mymailhost, mymailport) if mymailuser != "" and mymailpasswd != "": myconn.login(mymailuser, mymailpasswd) - msg = _unicode_encode(message.as_string(), - encoding=_encodings['content'], errors='backslashreplace') - myconn.sendmail(myfrom, myrecipient, msg) + myconn.sendmail(myfrom, myrecipient, message) myconn.quit() except smtplib.SMTPException as e: raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e)) |