ignore email sent from a mailbox to its alias if user.ignore_loop_email

This commit is contained in:
Son Nguyen Kim 2021-09-10 18:15:22 +02:00
parent 62044e6db1
commit 6e42e536db
2 changed files with 10 additions and 7 deletions

View File

@ -13,6 +13,8 @@ E207 = "250 SL E207 No bounce report"
E208 = "250 SL E208 Hotmail complaint handled" E208 = "250 SL E208 Hotmail complaint handled"
E209 = "250 SL E209 Email Loop"
# 4** errors # 4** errors
# E401 = "421 SL E401 Retry later" # E401 = "421 SL E401 Retry later"
E402 = "421 SL E402 Encryption failed - Retry later" E402 = "421 SL E402 Encryption failed - Retry later"

View File

@ -574,13 +574,14 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
else: else:
return [(False, status.E504)] return [(False, status.E504)]
# mail_from = envelope.mail_from if user.ignore_loop_email:
# for mb in alias.mailboxes: mail_from = envelope.mail_from
# # email send from a mailbox to alias for mb in alias.mailboxes:
# if mb.email == mail_from: # email send from a mailbox to its alias
# LOG.w("cycle email sent from %s to %s", mb, alias) if mb.email == mail_from:
# handle_email_sent_to_ourself(alias, mb, msg, user) LOG.w("cycle email sent from %s to %s", mb, alias)
# return [(True, "250 Message accepted for delivery")] handle_email_sent_to_ourself(alias, mb, msg, user)
return [(True, status.E209)]
from_header = get_header_unicode(msg["From"]) from_header = get_header_unicode(msg["From"])
LOG.d("Create or get contact for from_header:%s", from_header) LOG.d("Create or get contact for from_header:%s", from_header)