Created
May 1, 2013 00:32
-
-
Save jvanasco/5492944 to your computer and use it in GitHub Desktop.
Diff of patch to pyramid_mailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/pyramid_mailer/response.py | |
+++ b/pyramid_mailer/response.py | |
@@ -38,6 +38,7 @@ import quopri | |
import sys | |
import mimetypes | |
import string | |
+import types | |
from email.mime.base import MIMEBase | |
try: | |
@@ -324,8 +325,14 @@ class MailResponse(object): | |
if isinstance(self.Html, MailBase): | |
part.parts.append(self.Html) | |
elif self.Html: | |
+ try : | |
+ encoded = str(self.Html) | |
+ except UnicodeEncodeError: | |
+ (charset,charset_encoded) = encoding.best_charset(self.Html) | |
+ self.Html = charset_encoded | |
part.attach_text(self.Html, 'text/html') | |
+ | |
for args in self.attachments: | |
self._encode_attachment(**args) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment