def stderr_msg(self):
err_text = [u"Invalid email (particular type unknown):\n",
unicode(self), u"",
- send_pgp_mime.flatten(self.msg)]
+ send_pgp_mime.flatten(self.msg, to_unicode=True)]
return u"\n".join(err_text)
class InvalidSubject (InvalidEmail):
if LOGFILE != None:
LOGFILE.write("responding to %s: %s\n"
% (info["author_addr"], info["command"]))
- LOGFILE.write("\n%s\n\n" % send_pgp_mime.flatten(response_email.plain()))
+ LOGFILE.write("\n%s\n\n"
+ % send_pgp_mime.flatten(response_email.plain(),
+ to_unicode=True))
return response_email
def open_logfile(logpath=None):
sys.exit(1)
response_email = compose_response(ret, out_text, err_text, info).plain()
if options.output == True:
- print send_pgp_mime.flatten(response_email)
+ print send_pgp_mime.flatten(response_email, to_unicode=True)
else:
send_pgp_mime.mail(response_email, send_pgp_mime.sendmail)
close_logfile()
str = regexp.sub(replacement_text, str)
return str
-def flatten(msg):
+def flatten(msg, to_unicode=False):
"""
Produce flat text output from an email Message instance.
"""
g = Generator(fp, mangle_from_=False)
g.flatten(msg)
text = fp.getvalue()
- encoding = msg.get_content_charset()
- return unicode(text, encoding=encoding)
+ if to_unicode == True:
+ encoding = msg.get_content_charset()
+ text = unicode(text, encoding=encoding)
+ return text
def source_email(msg, return_realname=False):
"""