Step 1: Request outgoing port 25
Step 2: Set the hostname and reverse DNS
- Pick a mail hostname, for example
box.yourdomain.com(Mail-in-a-Box’s convention) ormail.yourdomain.com. - Create an A record for that hostname pointing to your server’s IP.
- Set the server’s reverse DNS to the same hostname from the Network tab of your server in the Billing Portal. See Configure Reverse DNS. Most large mail providers check that forward and reverse DNS match.
The core components
A mail server is several programs working together:- Postfix (SMTP): sends mail to other servers and receives mail for your domain.
- Dovecot (IMAP/POP3): lets mail apps such as Apple Mail, Outlook or Thunderbird read your mailbox.
- Spam and virus filtering: for example SpamAssassin or Rspamd, and ClamAV.
- DKIM signing: for example OpenDKIM, so receivers can verify your mail wasn’t altered.
The easier way: Mail-in-a-Box
Wiring those components together by hand takes hours. Mail-in-a-Box installs a complete mail server with webmail, contacts and calendar, and creates most DNS records for you. Its setup guide requires a fresh Ubuntu 22.04 server dedicated to mail; check the Mail-in-a-Box guide for the currently supported release before you deploy. Log in via SSH and run the official installer:This pipes a script from Mail-in-a-Box’s own site into a root shell. To review it first, download it with
curl -s https://mailinabox.email/setup.sh -o setup.sh, read it, then run sudo -E bash setup.sh.DNS records you need
If you skip these, your mail will land in spam folders or be rejected. Mail-in-a-Box can host DNS for you; otherwise add them at your DNS provider:- MX: tells other servers where to deliver mail for your domain.
- SPF: a TXT record listing which servers may send mail for your domain.
- DKIM: a TXT record with the public key that verifies your mail’s signature.
- DMARC: a TXT record telling receivers what to do with mail that fails SPF or DKIM.
- Reverse DNS (PTR): set in Step 2. Required by almost all major providers.