Running your own email server gives you full control over your domain emails. With a proper setup, you can send and receive emails securely and avoid being blacklisted. In this tutorial, we’ll use Postfix, Dovecot, and Let's Encrypt for TLS.
Step 1: Prepare Your VPS
-
Update your VPS:
-
Install essential packages:
-
Open necessary firewall ports:
Step 2: Configure Postfix
-
During installation, select “Internet Site”. Set your domain (e.g.,
yourdomain.com) as the system mail name. -
Edit
/etc/postfix/main.cfto include:
-
Reload Postfix:
Step 3: Configure Dovecot for IMAP
-
Enable Maildir format by editing
/etc/dovecot/conf.d/10-mail.conf:
-
Enable IMAPS by editing
/etc/dovecot/conf.d/10-ssl.conf:
-
Start and enable Dovecot:
Step 4: Create Mail Users
-
Add a Linux user (this will be the email account):
-
The Maildir is automatically created in
/home/john/Maildir.
Step 5: Set Up SPF, DKIM, and DMARC
-
SPF Record for your domain (example for DNS):
-
DKIM using OpenDKIM:
Configure and link to Postfix to sign outgoing emails.
-
DMARC:
These steps prevent emails from being flagged as spam.
Step 6: Test Your Email Server
-
Send a test email:
-
Check for delivery issues and logs:
✅ Tips & Best Practices
-
Use SSL/TLS for secure email.
-
Keep Postfix and Dovecot updated.
-
Monitor logs regularly for failed attempts or spam.
-
Avoid sending bulk emails from a self-hosted server unless properly configured — otherwise your VPS could get blacklisted.
-
Consider integrating Roundcube for a webmail interface.
With this setup, your VPS now runs a fully functional, secure email server for your domain, capable of sending and receiving emails safely.