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"
E209 = "250 SL E209 Email Loop"
# 4** errors
# E401 = "421 SL E401 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:
return [(False, status.E504)]
# mail_from = envelope.mail_from
# for mb in alias.mailboxes:
# # email send from a mailbox to alias
# if mb.email == mail_from:
# LOG.w("cycle email sent from %s to %s", mb, alias)
# handle_email_sent_to_ourself(alias, mb, msg, user)
# return [(True, "250 Message accepted for delivery")]
if user.ignore_loop_email:
mail_from = envelope.mail_from
for mb in alias.mailboxes:
# email send from a mailbox to its alias
if mb.email == mail_from:
LOG.w("cycle email sent from %s to %s", mb, alias)
handle_email_sent_to_ourself(alias, mb, msg, user)
return [(True, status.E209)]
from_header = get_header_unicode(msg["From"])
LOG.d("Create or get contact for from_header:%s", from_header)