Virtual mail domains and users in plain files

Table of Contents



by ross at 10:55:49 on April 2, 2018


1. Install Exim (skip other pages there)

Add Exim's mailnull user to mail group:

# pw groupmod mail -m mailnull

2. Eximanager - Exim setup (this will obviously overwrite existing configuration):

# cd /usr/local/etc/exim
# cp configure.sample configure
# fetch
# patch configure virtual.patch

Edit configure, find and set these two parameters:

primary_hostname =
qualify_domain =

Make Exim rewrite user@coffin.lan (change to your local hostname) or user@localhost as (add after begin rewrite line):

# Envelope "From" field, "From:" header 
*@coffin.lan $ Ff
*@localhost $ Ff

# Envelop "To" field, "To:" header
*@coffin.lan $ Tt
*@localhost $ Tt

3. Setup SSL (optional)

4. Activate smarthost relay (if your provider has one)

5. Install and enable SpamAssassin (optional, skip .forward creation if you do)


1. Install and configure Dovecot:

  • Enable SSL (optional)
  • Enable Maildir accounts.

2. Eximanager - Dovecot setup:

Modify conf.d/10-mail.conf:

first_valid_uid = 26
first_valid_gid = 6

Modify conf.d/10-auth.conf — uncomment the following line (near the end of file):

!include auth-passwdfile.conf.ext

Edit conf.d/auth-passwdfile.conf.ext:

  passdb {
    driver = passwd-file
    args = scheme=CRYPT username_format=%n /etc/mail/virtual/%d/master.passwd
  userdb {
    driver = passwd-file
    args = username_format=%n /etc/mail/virtual/%d/passwd


# service exim restart
# service dovecot restart