print_reply_only = handle_args()
+ email_bytes = sys.stdin.buffer.read()
+
+ test_auto_reply(email_bytes)
+
gpgme_ctx = get_gpg_context(edward_config.gnupghome,
edward_config.sign_with_key)
- email_bytes = sys.stdin.buffer.read()
-
# do this twice so sigs can be verified with newly imported keys
parse_pgp_mime(email_bytes, gpgme_ctx)
email_struct = parse_pgp_mime(email_bytes, gpgme_ctx)
return False
+def test_auto_reply (email_bytes):
+ """Test whether email is auto-generated
+
+ If the email is autogenerated, edward quits without sending a response.
+ This is not a perfect test. Some auto-responses will go undetected.
+
+ Args:
+ email_bytes: the byte string from of the email
+
+ Returns:
+ Nothing, or exits the program
+ """
+
+ email_struct = email.parser.BytesHeaderParser().parsebytes(email_bytes)
+
+ auto_submitted = email_struct['Auto-Submitted']
+
+ if auto_submitted == None or auto_submitted == "no" \
+ or auto_submitted == "No":
+
+ return
+
+ debug("autoreply")
+ exit(0)
+
+
def email_to_reply_to_subject (email_bytes):
"""Returns the email's To:, Reply-To: (or From:), and Subject: fields