diff --git a/pyas2lib/as2.py b/pyas2lib/as2.py index 67ee322..ff84f56 100644 --- a/pyas2lib/as2.py +++ b/pyas2lib/as2.py @@ -978,8 +978,9 @@ def detect_mdn(self): if part.get_content_type() == "message/disposition-notification": mdn = part.get_payload()[0] message_id = mdn.get("Original-Message-ID").strip("<>") - if mdn.get("Original-Recipient"): - message_recipient = mdn.get("Original-Recipient").split(";")[1].strip() - else: - message_recipient = mdn.get("Final-Recipient").split(";")[1].strip() + message_recipient = None + if "Original-Recipient" in mdn: + message_recipient = mdn["Original-Recipient"].split(";")[1].strip() + elif "Final-Recipient" in mdn: + message_recipient = mdn["Final-Recipient"].split(";")[1].strip() return message_id, message_recipient diff --git a/pyas2lib/tests/test_advanced.py b/pyas2lib/tests/test_advanced.py index 4e9650d..5947194 100644 --- a/pyas2lib/tests/test_advanced.py +++ b/pyas2lib/tests/test_advanced.py @@ -473,7 +473,7 @@ def setUp(self): verify_cert_ca=self.sb2bi_public_ca, encrypt_cert=self.sb2bi_public_key, encrypt_cert_ca=self.sb2bi_public_ca, - validate_certs=False + validate_certs=False, ) self.partner.load_verify_cert() self.partner.load_encrypt_cert()