mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-04 15:54:48 +01:00
let dovecot automatically create mailbox folders rather than doing it manually in the management daemon, fixes #554
This commit is contained in:
@@ -303,25 +303,6 @@ def add_mail_user(email, pw, privs, env):
|
||||
# write databasebefore next step
|
||||
conn.commit()
|
||||
|
||||
# Create & subscribe the user's INBOX, Trash, Spam, and Drafts folders.
|
||||
# * Our sieve rule for spam expects that the Spam folder exists.
|
||||
# * Roundcube will show an error if the user tries to delete a message before the Trash folder exists (#359).
|
||||
# * K-9 mail will poll every 90 seconds if a Drafts folder does not exist, so create it
|
||||
# to avoid unnecessary polling.
|
||||
|
||||
# Check if the mailboxes exist before creating them. When creating a user that had previously
|
||||
# been deleted, the mailboxes will still exist because they are still on disk.
|
||||
try:
|
||||
existing_mboxes = utils.shell('check_output', ["doveadm", "mailbox", "list", "-u", email, "-8"], capture_stderr=True).split("\n")
|
||||
except subprocess.CalledProcessError as e:
|
||||
c.execute("DELETE FROM users WHERE email=?", (email,))
|
||||
conn.commit()
|
||||
return ("Failed to initialize the user: " + e.output.decode("utf8"), 400)
|
||||
|
||||
for folder in ("INBOX", "Sent", "Trash", "Spam", "Drafts"):
|
||||
if folder not in existing_mboxes:
|
||||
utils.shell('check_call', ["doveadm", "mailbox", "create", "-u", email, "-s", folder])
|
||||
|
||||
# Update things in case any new domains are added.
|
||||
return kick(env, "mail user added")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user