This is an old revision of the document!
E-Mail server hosting
Everything in the following page is directly taken (and adjusted to my liking) from The Gentoo Virtual Mail Server guide which is a deep and very detailed read on the topic. I will stray a little bit from that guide.
Architecture
I will show you how to install and interconnect:
- Postfix, the MTA (Mail Transfer Agent)
- Dovecot, the IMAP server
- NGINX + PHP-FPM for web access (admin console + webmail)
- PostfixAdmin, the email configuration WEB gui
- Roundcube
- OpenDKIM
- OpenDMARC
- Spamassassin
Installation: servers
Install Postfix and Dovecot
USE flags:
echo "*/* maildir dovecot sasl" >> /etc/portage/package.use/mailserver echo "net-mail/dovecot managesieve sqlite lz4" >> /etc/portage/package.use/mailserver echo "mail-mta/postfix dovecot-sasl sqlite -sasl" >> /etc/portage/package.use/mailserver
Emerge the servers:
emerge -vp postfix dovecot
Installation: user, permissions & storage
Since different pieces of the email infrastructure will need to interoperate, it is a good idea to create a specific user to store all the emails on the filesystem. This user will own the email storage folders which i assume will be located under /home/vmail. I choose UID and GID 5000 since the ones <1000 are reserved for system users:
groupadd -g 5000 vmail useradd -m -d /home/vmail -s /bin/false -u 5000 -g vmail vmail chmod 2770 /home/vmail/
The resulting permissions should look like:
ls -ld /home/vmail drwxrws--- 3 vmail vmail 4096 Aug 2 07:24 /home/vmail
Installation: external packages
postfixadmin and roundcube will be installed manually and not via Gentoo portage, to avoid upgrade issues.
Configuration
FILE /etc/postfix/main.cfBinding UID and GID's to postfix
# Link the mailbox uid and gid to postfix. virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 # Set the base address for all virtual mailboxes virtual_mailbox_base = /var/vmail