aboutsummaryrefslogtreecommitdiffstats
path: root/interfaces/email/interactive
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces/email/interactive')
-rwxr-xr-xinterfaces/email/interactive/be-handle-mail2
-rw-r--r--interfaces/email/interactive/send_pgp_mime.py15
2 files changed, 12 insertions, 5 deletions
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail
index 01b75ac..3129ef4 100755
--- a/interfaces/email/interactive/be-handle-mail
+++ b/interfaces/email/interactive/be-handle-mail
@@ -188,8 +188,6 @@ def compose_response(ret, out_text, err_text, info):
response_header = [u"From: %s" % HANDLER_ADDRESS,
u"To: %s" % info["author_addr"],
u"Date: %s" % libbe.utility.time_to_str(time.time()),
- u"Content-Type: text/plain; charset=%s" % ENCODING,
- u"Content-Transfer-Encoding: 8bit",
u"Subject: %s Re: %s"%(SUBJECT_COMMENT,info["command"]),
]
if "message-id" in info:
diff --git a/interfaces/email/interactive/send_pgp_mime.py b/interfaces/email/interactive/send_pgp_mime.py
index a10674a..f66c626 100644
--- a/interfaces/email/interactive/send_pgp_mime.py
+++ b/interfaces/email/interactive/send_pgp_mime.py
@@ -80,6 +80,7 @@ have been warned.
verboseInvoke = False
PGP_SIGN_AS = None
PASSPHRASE = None
+DEFAULT_BODY_ENCODING = "UTF-8"
# The following commands are adapted from my .mutt/pgp configuration
#
@@ -164,7 +165,8 @@ def flatten(msg):
g = Generator(fp, mangle_from_=False)
g.flatten(msg)
text = fp.getvalue()
- return text
+ encoding = msg.get_content_charset()
+ return unicode(text, encoding=encoding)
def source_email(msg, return_realname=False):
"""
@@ -342,8 +344,15 @@ class Mail (object):
return source_email(self.headermsg)
def targetEmails(self):
return target_emails(self.headermsg)
+ def encodedMIMEText(self, body, encoding=None):
+ if encoding == None:
+ encoding = DEFAULT_BODY_ENCODING
+ if type(body) == types.StringType:
+ encoding = "US-ASCII"
+ # Create the message ('plain' stands for Content-Type: text/plain)
+ return MIMEText(body.encode(encoding), 'plain', encoding)
def clearBodyPart(self):
- body = MIMEText(self.body)
+ body = self.encodedMIMEText(self.body)
body.add_header('Content-Disposition', 'inline')
return body
def passphrase_arg(self, passphrase=None):
@@ -356,7 +365,7 @@ class Mail (object):
"""
text/plain
"""
- msg = MIMEText(self.body)
+ msg = self.encodedMIMEText(self.body)
for k,v in self.headermsg.items():
msg[k] = v
return msg