Just a collection of often-used commands with the IMAP server Dovecot, that will grow over time. It is not a complete Dovecot set-up guide.
Dovecot Add Users
This works only when using the Dovecot-internal user database. In my case, this is the file /etc/dovecot/users
. Add the following helper script and save it as /usr/local/bin/dovecot_add_user.sh
. Change the variable DOVECOT_PWD_FILE
or the password hashing scheme SHA512-CRYPT
if required. It needs to match the configuration in /etc/dovecot/conf.d/auth-passwdfile.conf.ext
.
#!/bin/bash
# Helper script to add new users to Dovecot internal user database.
DOVECOT_PWD_FILE="/etc/dovecot/users"
[ $# > 0 ] || exit 1
echo $1:$(doveadm pw -s SHA512-CRYPT) | tee -a $DOVECOT_PWD_FILE
Set the executable bit:
chmod 755 /usr/local/bin/dovecot_add_user.sh
Add a new user like this:
dovecot_add_user.sh newuser@example.com
Allow Access to Shared Folder
Any steps to initially set up shared folders (in the shared/user@example.com/
namespace) are omitted.
The example below uses the following users:
owner@example.com
– This user has permissions to grant access to the mailbox.assistant@example.com
– This user is granted access to the mailbox.shared/user@example.com/INBOX
– The mailbox that the assistant is granted access to.
doveadm acl set -u owner@example.com shared/user@example.com/INBOX user=assistant@example.com lookup read write write-seen insert
With the permissions above, the assistant cannot delete mails, but can mark them as seen and answered. See man doveadm-acl
for details.
Display Access to Shared Folder
This displays the access granted for a particular mailbox.
doveadm acl rights -u owner@example.com shared/user@example.com/INBOX
Revoke Access to Shared Folder
This deletes an ACL on a particular mailbox. Afterwards the user assistant@example.com
has no longer access to the specified mailbox.
doveadm acl delete -u owner@example.com shared/user@example.com/INBOX assistant@example.com
Remove Corrupted Message File
With sdbox mailbox format, if the logs indicate that a certain file is corrupted and cannot be read, here is how to get rid of this message:
doveadm expunge -u user@example.com MAILBOX INBOX UID 35835
35835
in the example above is the ID of the corrupted file as seen in the logs. It is prefixed by u.
like u.35835
.