catch exception

This commit is contained in:
Andreas Knuth 2026-01-25 15:36:56 -06:00
parent cf9bd4c9fb
commit 5108ad5a7d
1 changed files with 10 additions and 2 deletions

View File

@ -18,7 +18,15 @@ class BounceHandler:
@staticmethod
def is_ses_bounce_notification(parsed_email) -> bool:
"""Check if email is from SES MAILER-DAEMON"""
try:
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
def apply_bounce_logic(