aboutsummaryrefslogtreecommitdiffstats
path: root/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces')
-rwxr-xr-xinterfaces/email/interactive/be-handle-mail9
-rw-r--r--interfaces/email/interactive/send_pgp_mime.py (renamed from interfaces/email/interactive/send_pgp_mime)22
2 files changed, 21 insertions, 10 deletions
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail
index 7b62129..a608074 100755
--- a/interfaces/email/interactive/be-handle-mail
+++ b/interfaces/email/interactive/be-handle-mail
@@ -28,8 +28,9 @@ single argument.
Eventually we'll commit after every message.
"""
-import libbe.cmdutil, libbe.utility
+import cStringIO as StringIO
import email
+import libbe.cmdutil, libbe.utility
import send_pgp_mime
import sys
import time
@@ -111,11 +112,11 @@ def run_message(msg_text):
response_header = [u"From: %s" % HANDLER_ADDRESS,
u"To: %s" % author,
- u"Date: %s" % , libbe.utility.time_to_str(time.time()),
+ u"Date: %s" % libbe.utility.time_to_str(time.time()),
u"Content-Type: text/plain; charset=%s" % encoding,
u"Content-Transfer-Encoding: 8bit",
u"In-reply-to: %s" % (id),
- u"Subject: %s Re: %s" % (SUBJECT_COMMENT, command),
+ u"Subject: Re: %s %s" % (SUBJECT_COMMENT, command),
]
response_body = [u"Results of running: (exit code %d)" % ret,
u" %s %s" % (command, " ".join(command_args)),]
@@ -130,7 +131,7 @@ def run_message(msg_text):
def main():
msg_text = sys.stdin.read()
- response_email = handle_message(msg_text)
+ response_email = run_message(msg_text)
send_pgp_mime.mail(response_email, send_pgp_mime.sendmail)
if __name__ == "__main__":
diff --git a/interfaces/email/interactive/send_pgp_mime b/interfaces/email/interactive/send_pgp_mime.py
index 8aa86fa..d5a6497 100644
--- a/interfaces/email/interactive/send_pgp_mime
+++ b/interfaces/email/interactive/send_pgp_mime.py
@@ -18,10 +18,10 @@
"""
Python module and command line tool for sending pgp/mime email.
-Mostly uses subprocess to call gpg and a sendmail-compatible mailer
-(defaults to msmtp). If you lack gpg, either don't use the encryption
-functions or adjust the pgp_* commands. If you don't use msmtp,
-adjust the sendmail command.
+Mostly uses subprocess to call gpg and a sendmail-compatible mailer.
+If you lack gpg, either don't use the encryption functions or adjust
+the pgp_* commands. You may need to adjust the sendmail command to
+point to whichever sendmail-compatible mailer you have on your system.
"""
from cStringIO import StringIO
@@ -112,7 +112,7 @@ pgp_stdin_passphrase_arg='--passphrase-fd 0'
pgp_sign_command='/usr/bin/gpg --no-verbose --quiet --batch %p --output - --detach-sign --armor --textmode %?a?-u "%a"? %f'
pgp_encrypt_only_command='/usr/bin/gpg --no-verbose --quiet --batch --output - --encrypt --armor --textmode --always-trust --encrypt-to "%a" %R -- %f'
pgp_encrypt_sign_command='/usr/bin/gpg --no-verbose --quiet --batch %p --output - --encrypt --sign %?a?-u "%a"? --armor --textmode --always-trust --encrypt-to "%a" %R -- %f'
-sendmail='/usr/bin/msmtp -t'
+sendmail='/usr/sbin/sendmail -t'
def execute(args, stdin=None, expect=(0,)):
"""
@@ -339,6 +339,14 @@ class Mail (object):
if passphrase == None:
return (None,'')
return (passphrase, pgp_stdin_passphrase_arg)
+ def plain(self):
+ """
+ text/plain
+ """
+ msg = MIMEText(self.body)
+ for k,v in self.headermsg.items():
+ msg[k] = v
+ return msg
def sign(self, passphrase=None):
"""
multipart/signed
@@ -496,7 +504,7 @@ if __name__ == '__main__':
type="int", metavar='DESCRIPTOR')
parser.add_option('--mode', dest='mode', default='sign',
- help="One of 'sign', 'encrypt', or 'sign-encrypt'. Defaults to %default.",
+ help="One of 'sign', 'encrypt', 'sign-encrypt', or 'plain'. Defaults to %default.",
metavar='MODE')
parser.add_option('-a', '--sign-as', dest='sign_as',
@@ -554,6 +562,8 @@ if __name__ == '__main__':
message = m.encrypt()
elif options.mode == "sign-encrypt":
message = m.signAndEncrypt()
+ elif options.mode == "plain":
+ message = m.plain()
else:
print "Unrecognized mode '%s'" % options.mode