docker-mailserver/docs/content/config/user-management/accounts.md
2021-01-27 22:07:42 +01:00

3.1 KiB

Adding a new account

Users (email accounts) are managed in /tmp/docker-mailserver/postfix-accounts.cf.

The best way to manage accounts is to use the reliable setup.sh script.

Or you may directly add the full email address and its encrypted password, separated by a pipe.

Example:

user1@domain.tld|{SHA512-CRYPT}$6$2YpW1nYtPBs2yLYS$z.5PGH1OEzsHHNhl3gJrc3D.YMZkvKw/vp.r5WIiwya6z7P/CQ9GDEJDr2G2V0cAfjDFeAQPUoopsuWPXLk3u1
user2@otherdomain.tld|{SHA512-CRYPT}$6$2YpW1nYtPBs2yLYS$z.5PGH1OEzsHHNhl3gJrc3D.YMZkvKw/vp.r5WIiwya6z7P/CQ9GDEJDr2G2V0cAfjDFeAQPUoopsuWPXLk3u1

In the example above, we've added 2 mail accounts for 2 different domains. Consequently, the mail-server will automagically be configured as multi-domains.

Therefore, to generate a new mail account data, directly from your docker host, you could for example run the following:

docker run --rm \
  -e MAIL_USER=user1@domain.tld \
  -e MAIL_PASS=mypassword \
  -ti tvial/docker-mailserver:latest \
  /bin/sh -c 'echo "$MAIL_USER|$(doveadm pw -s SHA512-CRYPT -u $MAIL_USER -p $MAIL_PASS)"' >> config/postfix-accounts.cf

You will then be asked for a password, and be given back the data for a new account entry, as text.

To actually add this new account, just copy all the output text in config/postfix-accounts.cf file of your running container.

Please note the doveadm pw command lets you choose between several encryption schemes for the password. Use doveadm pw -l to get a list of the currently supported encryption schemes.

Note: changes to the accounts list require a restart of the container, using supervisord. See #552


Mailbox quota

On top of the default quota (POSTFIX_MAILBOX_SIZE_LIMIT), you can define specific quotas per mailbox. Quota implementation relies on dovecot quota which requires dovecot to be enabled. Consequently, quota directives are disabled when SMTP_ONLY=1 or when ENABLE_LDAP=1 or when explicitly disabled with ENABLE_QUOTAS=0.

A warning message will be sent to the user when his mailbox is reaching quota limit. Have a look at 90-quota.cf for further details.

Commands

exec in the container

  • setquota <user@domain.tld> [<quota>]: define the quota of a mailbox (quota format e.g. 302M (B (byte), k (kilobyte), M (megabyte), G (gigabyte) or T (terabyte)))
  • delquota <user@domain.tld>: delete the quota of a mailbox
  • doveadm quota get -u <user@domain>: display the quota and the statistics of a mailbox

dovecot-quotas.cf

This file is a key-value database where quotas are stored.

dovecot-quotas.cf

user@domain.tld:50M
john@other-domain.tld:1G

Notes

  • imap-quota is enabled and allow clients to query their mailbox usage.
  • When the mailbox is deleted, the quota directive is deleted as well.
  • LDAP ? Dovecot quotas supports LDAP but it's not implemented (PR are welcome!).