From 3f2fe9c57ba89818af4b80636087c6dfba1d329e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 17 Jul 2009 08:16:45 -0400 Subject: "be-handle-mail --output" added to support easy testing. --- interfaces/email/interactive/be-handle-mail | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'interfaces/email') diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index e0ed584..180320d 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -212,6 +212,15 @@ def compose_response(ret, out_text, err_text, info): return response_email def main(): + from optparse import OptionParser + + usage="be-handle-mail [options]\n\n%s" % (__doc__) + parser = OptionParser(usage=usage) + parser.add_option('-o', '--output', dest='output', action='store_true', + help="Don't mail the generated message, print it to stdout instead. Useful for testing be-handle-mail functionality without the whole mail transfer agent and procmail setup.") + + options,args = parser.parse_args() + msg_text = sys.stdin.read() try: ret,out_text,err_text,info = run_message(msg_text) @@ -223,8 +232,11 @@ def main(): f.write("Uncaught exception:\n%s\n" % (e,)) f.close() sys.exit(1) - response_email = compose_response(ret, out_text, err_text, info) - send_pgp_mime.mail(response_email.plain(), send_pgp_mime.sendmail) + response_email = compose_response(ret, out_text, err_text, info).plain() + if options.output == True: + print send_pgp_mime.flatten(response_email) + else: + send_pgp_mime.mail(response_email, send_pgp_mime.sendmail) if __name__ == "__main__": main() -- cgit