catch exception
This commit is contained in:
parent
cf9bd4c9fb
commit
5108ad5a7d
|
|
@ -18,7 +18,15 @@ class BounceHandler:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_ses_bounce_notification(parsed_email) -> bool:
|
def is_ses_bounce_notification(parsed_email) -> bool:
|
||||||
"""Check if email is from SES MAILER-DAEMON"""
|
"""Check if email is from SES MAILER-DAEMON"""
|
||||||
|
try:
|
||||||
from_header = (parsed_email.get('From') or '').lower()
|
from_header = (parsed_email.get('From') or '').lower()
|
||||||
|
except (AttributeError, TypeError, KeyError):
|
||||||
|
# Malformed From header - safely extract raw value
|
||||||
|
try:
|
||||||
|
from_header = str(parsed_email.get_all('From', [''])[0]).lower()
|
||||||
|
except:
|
||||||
|
from_header = ''
|
||||||
|
|
||||||
return 'mailer-daemon@' in from_header and 'amazonses.com' in from_header
|
return 'mailer-daemon@' in from_header and 'amazonses.com' in from_header
|
||||||
|
|
||||||
def apply_bounce_logic(
|
def apply_bounce_logic(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue