Virtual mail domains and users in plain files

Table of Contents

Introduction
Configuration
Usage

Configuration

by ross at 06:00:08 on July 3, 2018

Exim

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 http://daemon-notes.com/downloads/assets/patches/virtual.patch
# patch configure virtual.patch

Edit configure, find and set these two parameters:

primary_hostname = mx.example.com
qualify_domain = example.com

Find this section:

accept  authenticated = *
           control       = submission
           control       = dkim_disable_verify

And replace it with this:

accept  authenticated = *
           control       = submission/sender_retain/domain=
           control       = dkim_disable_verify

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

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

# Envelop "To" field, "To:" header
*@coffin.lan $local_part@example.com Tt
*@localhost $local_part@example.com 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)

Dovecot

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
  }

Done

# service exim restart
# service dovecot restart

 

Comments