add warning for when postfix queue id can't be retrieved

This commit is contained in:
Son NK 2021-06-23 18:19:13 +02:00
parent b84eb13ab5
commit 58a1d6e783
1 changed files with 6 additions and 4 deletions

View File

@ -1547,14 +1547,16 @@ def handle(envelope: Envelope) -> str:
envelope.mail_from = mail_from
envelope.rcpt_tos = rcpt_tos
if should_ignore(mail_from, rcpt_tos):
LOG.e("Ignore email mail_from=%s rcpt_to=%s", mail_from, rcpt_tos)
return "250 email can't be sent from a reverse-alias"
msg = email.message_from_bytes(envelope.original_content)
postfix_queue_id = get_queue_id(msg)
if postfix_queue_id:
set_message_id(postfix_queue_id)
else:
LOG.w("Cannot parse Postfix queue ID from %s", msg["Received"])
if should_ignore(mail_from, rcpt_tos):
LOG.e("Ignore email mail_from=%s rcpt_to=%s", mail_from, rcpt_tos)
return "250 email can't be sent from a reverse-alias"
# sanitize email headers
sanitize_header(msg, "from")