mirror of
https://github.com/simple-login/app.git
synced 2025-02-24 15:53:22 +08:00
add disable_mailbox to shell
This commit is contained in:
parent
3d0d42c8b3
commit
edfd3c0719
1 changed files with 31 additions and 0 deletions
31
shell.py
31
shell.py
|
@ -114,6 +114,37 @@ def migrate_domain_trash():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def disable_mailbox(mailbox_id):
|
||||||
|
"""disable a mailbox and all of its aliases"""
|
||||||
|
mailbox = Mailbox.get(mailbox_id)
|
||||||
|
mailbox.verified = False
|
||||||
|
for alias in mailbox.aliases:
|
||||||
|
alias.enabled = False
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
email_msg = f"""Hi,
|
||||||
|
|
||||||
|
Your mailbox {mailbox.email} cannot receive emails.
|
||||||
|
To avoid forwarding emails to an invalid mailbox, we have disabled this mailbox along with all of its aliases.
|
||||||
|
|
||||||
|
If this is a mistake, please reply to this email.
|
||||||
|
|
||||||
|
Thanks,
|
||||||
|
SimpleLogin team.
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
send_email(
|
||||||
|
mailbox.user.email,
|
||||||
|
f"{mailbox.email} is disabled",
|
||||||
|
email_msg,
|
||||||
|
email_msg.replace("\n", "<br>"),
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
LOG.error("Cannot send disable mailbox email to %s", mailbox.user)
|
||||||
|
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|
Loading…
Reference in a new issue