-def email_to_from_subject (email_bytes):
- """Returns the values of the email's To:, From: and Subject: fields
+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