Virtual mail domains and users in plain files

Table of Contents



by ross at 11:08:21 on April 27, 2017


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 [email protected] (change to your local hostname) or [email protected] as [email protected] (add after begin rewrite line):

# Envelope "From" field, "From:" header 
[email protected] [email protected] Ff
[email protected] [email protected] Ff

# Envelop "To" field, "To:" header
[email protected] [email protected] Tt
[email protected] [email protected] 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 passwd-file {
    args = scheme=CRYPT username_format=%n /etc/mail/virtual/%d/master.passwd
  userdb passwd-file {
    args = username_format=%n /etc/mail/virtual/%d/passwd


# service exim restart
# service dovecot restart