Create Courier-imap server certificate:
sudo pico /etc/courier/imapd.cnf &&
sudo rm /etc/courier/imapd.pem &&
sudo /usr/lib/courier/mkimapdcert &&
sudo /etc/init.d/courier-imap restart &&
sudo /etc/init.d/courier-imap-ssl restart

Virtual users:

  1. add authuserdb to /etc/courier/authdaemonrc modulelist command
  2. pw2userdb >> /etc/courier/userdb && chmod 0700 /etc/courier/userdb
  3. edit /etc/courier/userdb and
    1. add @domain.tld to the user’s name
    2. remove shell= option
    3. optionally – change systempwd to imapwd
  4. optionally: add other users using
    userdb “john@domain.tld” set home=/home/vmail mail=/home/vmail/domain.tld/john uid=UUU gid=GGG
  5. finally, makeuserdb

Done with Courier, it’s time to set up Postfix:

Add virtual domain and user support to Postfix:

add to to main.cf:

virtual_mailbox_domains = domain.tld
virtual_mailbox_base = /var/mail/vmail
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000
virtual_gid_maps = static:8
virtual_alias_maps = hash:/etc/postfix/virtual

mkdir /var/mail/vmail/domain.tld && chown 5000:mail /var/mail/vmail/domain.tld

add to /etc/postfix/vmailbox:

domain.tld DOMAIN
@domain.tld domain.tld/info.Maildir
postmaster@domain.tld domain.tld/webmaster/Maildir/
info@domain.tld ddomain.tld/info/Maildir/

also, well known aliasies to /etc/postfix/virtual:

postmaster@domain.tld user@domain.tld
hostmaster@domain.tld user@domain.tld
abuse@domain.tld user@domain.tld

postmap hash:/etc/postfix/virtual && postmap hash:/etc/postfix/vmailbox && /etc/init.d/postfix reload

That’s all. Watch the logs 😉