disable email forwards/sending if user is disabled
This commit is contained in:
parent
7e425c0338
commit
6993721ae2
|
@ -453,6 +453,12 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
|
||||||
LOG.d("alias %s cannot be created on-the-fly, return 550", address)
|
LOG.d("alias %s cannot be created on-the-fly, return 550", address)
|
||||||
return [(False, "550 SL E3 Email not exist")]
|
return [(False, "550 SL E3 Email not exist")]
|
||||||
|
|
||||||
|
if alias.user.disabled:
|
||||||
|
LOG.exception(
|
||||||
|
"User %s disabled, disable forwarding emails for %s", alias.user, alias
|
||||||
|
)
|
||||||
|
return [(False, "550 SL E20 Account disabled")]
|
||||||
|
|
||||||
mail_from = envelope.mail_from
|
mail_from = envelope.mail_from
|
||||||
for mb in alias.mailboxes:
|
for mb in alias.mailboxes:
|
||||||
# email send from a mailbox to alias
|
# email send from a mailbox to alias
|
||||||
|
@ -713,6 +719,15 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
||||||
user = alias.user
|
user = alias.user
|
||||||
mail_from = envelope.mail_from
|
mail_from = envelope.mail_from
|
||||||
|
|
||||||
|
if user.disabled:
|
||||||
|
LOG.exception(
|
||||||
|
"User %s disabled, disable sending emails from %s to %s",
|
||||||
|
user,
|
||||||
|
alias,
|
||||||
|
contact,
|
||||||
|
)
|
||||||
|
return [(False, "550 SL E20 Account disabled")]
|
||||||
|
|
||||||
# bounce email initiated by Postfix
|
# bounce email initiated by Postfix
|
||||||
# can happen in case emails cannot be delivered to user-email
|
# can happen in case emails cannot be delivered to user-email
|
||||||
# in this case Postfix will try to send a bounce report to original sender, which is
|
# in this case Postfix will try to send a bounce report to original sender, which is
|
||||||
|
|
Loading…
Reference in New Issue