Skip to content

Creating an Archive Mailbox with Dovecot

Purpose

When you ISP's mail-server quotum is reached, you can archive your mail into a separate server locally on your own server. And it is accessible by multiple local users.

Install Dovecot

apt instlall dovecot-imapd

Create Archive User

The archive user is created with the following command:

useradd --system --no-create-home --shell /sbin/nologin --uid 900 --gid office archive

Dovecot Variable Expansion

List of available variables for expansion:

Variable Expands to
%u full username (e.g. archive)
%n username without domain (useful if using user@domain format)
%d domain part only (e.g. example.com)
%h home directory of the user
%l first letter of username (useful for sharding)
%L lowercase version of the following variable
%U uppercase version of the following variable

Change the Storage Location

To change the storage location of the archive mailbox, edit file /etc/dovecot/conf.d/10-mail.conf and change the line mail_location = ... to:

mail_location = maildir:/mnt/data/mail/%n/files:LAYOUT=fs:INDEX=/mnt/data/mail/%n/index
mail_access_groups = office

To allow the archive user to access the storage location, set the sticky bit on the directory for the group:

chmod g+rs /mnt/data/mail

Only the files subdirectory needs this since eml-files are only in that directory.