Skip to content

Instantly share code, notes, and snippets.

@jvanasco
Created May 1, 2013 00:32
Show Gist options
  • Save jvanasco/5492944 to your computer and use it in GitHub Desktop.
Save jvanasco/5492944 to your computer and use it in GitHub Desktop.
Diff of patch to pyramid_mailer
--- 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