diff --git a/core/mail/protocol.py b/core/mail/protocol.py index 48b446f..3aa1f98 100644 --- a/core/mail/protocol.py +++ b/core/mail/protocol.py @@ -1,4 +1,5 @@ import logging +from re import match import aiosmtplib from channels.layers import get_channel_layer @@ -201,17 +202,17 @@ def receive_email(envelope, log=None): header_in_reply_to = parsed.get('In-Reply-To') header_message_id = parsed.get('Message-ID') - if header_from != envelope.mail_from: - log.warning("Header from does not match envelope from") - log.info(f"Header from: {header_from}, envelope from: {envelope.mail_from}") +# if header_from != envelope.mail_from: +# log.warning("Header from does not match envelope from") +# log.info(f"Header from: {header_from}, envelope from: {envelope.mail_from}") +# +# if header_to != envelope.rcpt_tos[0]: +# log.warning("Header to does not match envelope to") +# log.info(f"Header to: {header_to}, envelope to: {envelope.rcpt_tos[0]}") - if header_to != envelope.rcpt_tos[0]: - log.warning("Header to does not match envelope to") - log.info(f"Header to: {header_to}, envelope to: {envelope.rcpt_tos[0]}") + # handle undelivered mail header_from : 'Mail Delivery System ").startswith('MAILER-DAEMON@') and envelope.mail_from.strip("<>") == "": + if match(r'^[a-zA-Z ]*") == "": log.warning("Ignoring mailer daemon") raise SpecialMailException("Ignoring mailer daemon")