let dovecot automatically create mailbox folders rather than doing it manually in the management daemon, fixes #554
This commit is contained in:
parent
5e7b7835b7
commit
274e5ca676
3 changed files with 58 additions and 19 deletions
55
conf/dovecot-mailboxes.conf
Normal file
55
conf/dovecot-mailboxes.conf
Normal file
|
@ -0,0 +1,55 @@
|
|||
## NOTE: This file is automatically generated by Mail-in-a-Box.
|
||||
## Do not edit this file. It is continually updated by
|
||||
## Mail-in-a-Box and your changes will be lost.
|
||||
##
|
||||
## Mail-in-a-Box machines are not meant to be modified.
|
||||
## If you modify any system configuration you are on
|
||||
## your own --- please do not ask for help from us.
|
||||
|
||||
namespace inbox {
|
||||
# Automatically create & subscribe some folders.
|
||||
# * Create and subscribe the INBOX folder.
|
||||
# * 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.
|
||||
# * Apple's OS X Mail app will create 'Sent Messages' if it doesn't see a folder with the \Sent flag. (#571, #573)
|
||||
|
||||
# auto:
|
||||
# 'create' will automatically create this mailbox.
|
||||
# 'subscribe' will both create and subscribe to the mailbox.
|
||||
|
||||
# special_use is a space separated list of IMAP SPECIAL-USE
|
||||
# attributes as specified by RFC 6154:
|
||||
# \All \Archive \Drafts \Flagged \Junk \Sent \Trash
|
||||
|
||||
mailbox INBOX {
|
||||
auto = subscribe
|
||||
}
|
||||
mailbox Spam {
|
||||
special_use = \Junk
|
||||
auto = subscribe
|
||||
}
|
||||
mailbox Drafts {
|
||||
special_use = \Drafts
|
||||
auto = subscribe
|
||||
}
|
||||
mailbox Sent {
|
||||
special_use = \Sent
|
||||
auto = subscribe
|
||||
}
|
||||
mailbox Trash {
|
||||
special_use = \Trash
|
||||
auto = subscribe
|
||||
}
|
||||
|
||||
# dovevot's standard mailboxes configuration file marks two sent folders
|
||||
# with the \Sent attribute, just in case clients don't agree about which
|
||||
# they're using. We'll keep that, plus add Junk as an alterative for Spam.
|
||||
# These are not auto-created.
|
||||
mailbox "Sent Messages" {
|
||||
special_use = \Sent
|
||||
}
|
||||
mailbox Junk {
|
||||
special_use = \Junk
|
||||
}
|
||||
}
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ tools/editconf.py /etc/dovecot/conf.d/10-mail.conf \
|
|||
mail_privileged_group=mail \
|
||||
first_valid_uid=0
|
||||
|
||||
# Create, subscribe, and mark as special folders: INBOX, Drafts, Sent, Trash, and Spam.
|
||||
cp conf/dovecot-mailboxes.conf /etc/dovecot/conf.d/15-mailboxes.conf
|
||||
|
||||
# ### IMAP/POP
|
||||
|
||||
# Require that passwords are sent over SSL only, and allow the usual IMAP authentication mechanisms.
|
||||
|
|
Loading…
Reference in a new issue