Setup Email Server From Scratch On FreeBSD #2
We believe in data independence, and support others who want data independence.
This tutorial is partially complete 2025-08-07
This is version 2 and everthing works up to and including Roundcube.
My two favorite operating systems for servers are FreeBSD and Debian. In 1994 I switched from Linux to FreeBSD and after more development found I was unable to migrate my main project back to Linux (at that time). Fast forward 30 years. My website runs on FreeBSD with an Ubuntu bhyve virtual machine running Zimbra Mail. Forwarding ports with ipfw (kernel level firewall) to the internal VM is tricky, and a couple times a year the Zimbra VM stops working and needs to be rebooted. It would be better to install and run the email stack natively on the FreeBSD server. Years ago I tried the Purple Hat Maia install which rendered my server unusable and required a rebuild. There have been some requests in forums for updated mail install on a current version of FreeBSD.
This is version 2, we will try to stick to packages as much as possible.
This tutorial is based on Linuxbabe - Build Email Server From Scratch on Debian. This is my 4th mail from scratch install, 1) Debian-12.8 2) FreeBSD-14.2 3) Debian-12.11, and this install on 4) FreebSD 14.3.
Note that mixing packages and ports is generally discouraged. For this howto I use a text file knowledgebase with no html or images.
File edits or contents start with and end with '# ---' sometimes with an additional message like '# --- additional message ---'. Do not include these lines in the files. Also in some place I put a line with three dots, do not include these. The 3 dots indicate that the files has more lines between and to skip farther down in the file to continue editing.
Generally configuration file comments start with '#' or in some cases ';'. PHP files use a double slash for comments like '// This is a comment'. If you don't want to loose the default values, comment them out and add a line with the new setting. Or, if required remove the comment to enable the setting. Generally if you set the same value twice in a configuration file the last one will be used, or often the software will refuse to start with an error saying the value is set twice, or just refuse to start with no obvious error. So check the logs in the /var/log directory.
01 Server Setup
02 FAMP Install
03 Postfix SMTPD
04 Dovecot IMAP
05 PostfixAdmin
06 SPF DMARC And DKIM
07 RoundCube WebMail
09 Create Virtual Domains
10 Blocking Spam
25 IMAPSYNC
80 Bind DNS
99 FreeBSD NAT64 Router