This guide ties together everything needed for a fully functional, properly authenticated self-hosted mail server — combining the individual pieces covered in other guides into one end-to-end checklist and order of operations.
What You'll End Up With
- Postfix handling outbound/inbound SMTP
- Dovecot providing IMAP/POP3 access for mail clients
- Full SPF, DKIM, and DMARC authentication
- Correct reverse DNS (PTR)
- TLS encryption throughout
Prerequisites
- A dedicated VPS with a dedicated IPv4 address
- A domain you control with DNS access
- Root or sudo access
Step 1 — Set the Hostname
sudo hostnamectl set-hostname mail.yourdomain.com
Step 2 — Create the Forward DNS (A) Record
Type: A
Name: mail
Value: YOUR_SERVER_IP
Step 3 — Request the PTR Record from Your Provider
See How to Set Up Reverse DNS (PTR/rDNS) for Email Deliverability for the full process.
Step 4 — Obtain a TLS Certificate
sudo apt install certbot -y
sudo certbot certonly --standalone -d mail.yourdomain.com
Step 5 — Install and Configure Postfix
Follow How to Install and Configure Postfix as a Mail Transfer Agent in full.
Step 6 — Install and Configure Dovecot
Follow How to Install and Configure Dovecot for IMAP/POP3 in full, including connecting it to Postfix for SASL authentication.
Step 7 — Configure DKIM Signing
sudo apt install opendkim opendkim-tools -y
sudo mkdir -p /etc/opendkim/keys/yourdomain.com
sudo opendkim-genkey -s default -d yourdomain.com -D /etc/opendkim/keys/yourdomain.com
Connect OpenDKIM to Postfix:
sudo nano /etc/postfix/main.cf
milter_default_action = accept
milter_protocol = 6
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
sudo systemctl restart opendkim postfix
Step 8 — Publish DNS Records
Add all three at once:
SPF (TXT @): v=spf1 ip4:YOUR_SERVER_IP -all
DKIM (TXT default._domainkey): v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY
DMARC (TXT _dmarc): v=DMARC1; p=none; rua=mailto:[email protected]
See How to Configure SPF, DKIM, and DMARC (Complete Guide) for full detail on each.
Step 9 — Create Mailboxes
sudo adduser john
Each Linux system user automatically gets a mailbox under Dovecot's default Maildir configuration.
Step 10 — Configure the Firewall
sudo ufw allow 25/tcp
sudo ufw allow 587/tcp
sudo ufw allow 465/tcp
sudo ufw allow 993/tcp
sudo ufw allow 995/tcp
Step 11 — Full End-to-End Test
- Send a test email to a Gmail account
- Open it and select "Show original"
- Confirm SPF, DKIM, and DMARC all show
PASS - Configure a mail client (Thunderbird, Outlook, or your phone) using the IMAP/SMTP settings from the Dovecot guide, and confirm you can send and receive
Step 12 — Warm Up Before Sending Volume
If this server will send marketing or bulk mail, follow IP Warm-Up: A Safe 30-Day Schedule for New Sending IPs before ramping up volume.
Common Errors
See the dedicated troubleshooting guide: How to Troubleshoot Email Not Sending or Going to Spam.
Best Practices
- Complete every step above before sending any real mail — partial configuration is a common cause of poor deliverability
- Test with Gmail's header inspection after every significant configuration change
- Keep the server updated and monitor logs regularly
Continue Reading
- How to Install and Configure Postfix as a Mail Transfer Agent
- How to Install and Configure Dovecot for IMAP/POP3
- How to Configure SPF, DKIM, and DMARC (Complete Guide)
- How to Troubleshoot Email Not Sending or Going to Spam
Browse more articles in Email Hosting & Deliverability.
