in emails/views.py [0:0]
def _get_relay_recipient_from_message_json(message_json):
# Go thru all To, Cc, and Bcc fields and
# return the one that has a Relay domain
# First check common headers for to or cc match
headers_to_check = "to", "cc"
common_headers = message_json["mail"]["commonHeaders"]
for header in headers_to_check:
if header in common_headers:
recipient = _get_recipient_with_relay_domain(common_headers[header])
if recipient is not None:
return parseaddr(recipient)[1]
# SES-SNS sends bcc in a different part of the message
recipients = message_json["receipt"]["recipients"]
return _get_recipient_with_relay_domain(recipients)