This commit is contained in:
j3d1 2024-05-04 02:07:13 +02:00
parent 83299bba7a
commit dbbd63ab1e

View file

@ -1,4 +1,5 @@
import logging import logging
from re import match
import aiosmtplib import aiosmtplib
from channels.layers import get_channel_layer 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_in_reply_to = parsed.get('In-Reply-To')
header_message_id = parsed.get('Message-ID') header_message_id = parsed.get('Message-ID')
if header_from != envelope.mail_from: # if header_from != envelope.mail_from:
log.warning("Header from does not match envelope from") # log.warning("Header from does not match envelope from")
log.info(f"Header from: {header_from}, envelope from: {envelope.mail_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]: # handle undelivered mail header_from : 'Mail Delivery System <MAILER-DAEMON@...'
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 'MAILER-DAEMON@' if match(r'^[a-zA-Z ]*<?MAILER-DAEMON@', header_from) and envelope.mail_from.strip("<>") == "":
if header_from.strip("<>").startswith('MAILER-DAEMON@') and envelope.mail_from.strip("<>") == "":
log.warning("Ignoring mailer daemon") log.warning("Ignoring mailer daemon")
raise SpecialMailException("Ignoring mailer daemon") raise SpecialMailException("Ignoring mailer daemon")