Running your own mail server gives you complete control over your email infrastructure, from custom domains and unlimited mailboxes to full privacy without relying on third-party providers like Gmail or Outlook. This guide walks you through installing and configuring a production-ready mail server on a FlashRDP Linux VPS using Postfix (SMTP), Dovecot (IMAP/POP3), and essential security layers like SPF, DKIM, and DMARC.
Last updated: May 8, 2026
Self-hosting email is one of the most rewarding (and educational) projects you can run on a VPS. According to Radicati Group's 2025 Email Statistics Report, over 376 billion emails are sent daily worldwide, and while most people rely on hosted email services, the privacy-conscious and technically minded increasingly choose self-hosted solutions.
Prerequisites
Before you begin, make sure you have:
- A FlashRDP Linux VPS with at least 2 vCPU, 2 GB RAM, and Ubuntu 22.04/24.04 or Debian 12
- A registered domain name (e.g.,
yourdomain.com) - Root (sudo) access to your VPS
- A clean IP address (not on any email blacklists)
- DNS access to configure MX, A, SPF, DKIM, and DMARC records
💡 Tip FlashRDP Linux VPS plans include full root access, 1 Gbps unmetered bandwidth, and clean IPs suitable for mail server hosting. Plans start at $11.99/month. View Linux VPS plans.
Step 1: Initial Server Setup
1.1 Update and Secure Your VPS
Connect to your server via SSH and run the initial setup:
1.2 Configure the Firewall
Open only the ports needed for email and SSH:
Step 2: Configure DNS Records
Before installing any mail software, configure your DNS records with your domain registrar. These are critical for mail delivery and authentication.
2.1 Essential DNS Records
| Record Type | Name | Value | TTL |
|---|---|---|---|
| A | mail.yourdomain.com | YOUR_SERVER_IP | 300 |
| MX | yourdomain.com | mail.yourdomain.com (Priority: 10) | 300 |
| SPF (TXT) | yourdomain.com | v=spf1 mx a ip4:YOUR_SERVER_IP -all | 300 |
| DMARC (TXT) | _dmarc.yourdomain.com | v=DMARC1; p=quarantine; rua=mailto:postmaster@yourdomain.com | 300 |
| PTR (rDNS) | YOUR_SERVER_IP | mail.yourdomain.com | 300 |
ℹ️ Note The PTR (reverse DNS) record can be configured directly from your FlashRDP service area. Navigate to Service Area > Network tab and set your rDNS hostname to
mail.yourdomain.com. Changes typically propagate within a few minutes.
2.2 Verify DNS Propagation
Step 3: Install SSL/TLS Certificate
A valid TLS certificate is essential for encrypted email transmission. We will use Let's Encrypt for free certificates.
Set up automatic renewal:
Step 4: Install and Configure Postfix (SMTP)
Postfix handles outgoing and incoming email delivery (SMTP).
4.1 Install Postfix
4.2 Configure Postfix Main Settings
Edit the main configuration file:
Replace/merge with the following configuration:
4.3 Configure Submission Port (587)
Edit the master configuration:
Uncomment/add the submission block:
4.4 Restart Postfix
Step 5: Install and Configure Dovecot (IMAP/POP3)
Dovecot handles mailbox access, letting you read email from clients like Thunderbird, Outlook, or Apple Mail.
5.1 Install Dovecot
5.2 Configure Dovecot Mail Location
Set the mail location to Maildir format:
5.3 Configure Authentication
5.4 Configure TLS
5.5 Configure Dovecot for Postfix SASL
Find the service auth section and configure it:
5.6 Restart Dovecot
Step 6: Create Email Accounts
Create system users for each email address. Each system user corresponds to one mailbox.
Repeat for additional mailboxes:
Step 7: Configure DKIM (DomainKeys Identified Mail)
DKIM adds a cryptographic signature to every outgoing email, proving it came from your server and was not tampered with in transit.
7.1 Install OpenDKIM
7.2 Configure OpenDKIM
Add/modify these settings:
7.3 Create DKIM Keys
7.4 Configure DKIM Tables
7.5 Get the DKIM DNS Record
Copy the output and add it as a TXT record in your DNS:
| Record Type | Name | Value |
|---|---|---|
| TXT | mail._domainkey.yourdomain.com | (paste the full DKIM key from the command output) |
7.6 Connect OpenDKIM to Postfix
Add the following to /etc/postfix/main.cf:
Restart both services:
Step 8: Test Your Mail Server
8.1 Send a Test Email
8.2 Check Mail Logs
8.3 Verify DKIM and SPF
After receiving the test email, check the headers in Gmail:
- Open the email in Gmail
- Click the three dots menu and select "Show original"
- Look for SPF: PASS, DKIM: PASS, and DMARC: PASS
8.4 Use Online Testing Tools
- mail-tester.com - Comprehensive deliverability scoring (aim for 9+/10)
- mxtoolbox.com - DNS and blacklist checking
- dkimvalidator.com - DKIM signature validation
Step 9: Install Webmail (Optional)
For browser-based email access, install Roundcube:
Configure Apache for Roundcube:
Then visit https://mail.yourdomain.com and follow the Roundcube installer.
Step 10: Harden and Maintain Your Mail Server
10.1 Install Fail2Ban
Protect against brute-force attacks on your mail server:
10.2 Set Up Log Rotation
10.3 Monitor Blacklists
Regularly check if your server IP is on any email blacklists:
Or visit mxtoolbox.com/blacklists.aspx and enter your server IP.
10.4 Automatic Certificate Renewal
Ensure Let's Encrypt certificates renew and services reload automatically:
Mail Server Architecture Overview
Here is how the components work together:
| Component | Role | Port(s) |
|---|---|---|
| Postfix | SMTP server (sends/receives mail) | 25, 587, 465 |
| Dovecot | IMAP/POP3 server (mailbox access) | 143, 993, 110, 995 |
| OpenDKIM | Signs outgoing mail with DKIM | 12301 (internal) |
| Let's Encrypt | TLS certificates | N/A |
| Fail2Ban | Brute-force protection | N/A |
| Roundcube | Webmail interface (optional) | 443 |
Troubleshooting Common Issues
Emails Going to Spam
- Check SPF, DKIM, and DMARC records are all configured and passing
- Verify rDNS (PTR record) matches your mail hostname
- Test with mail-tester.com for a detailed deliverability score
- Warm up your IP by sending small volumes initially and gradually increasing
Connection Refused on Port 25
- Check if your hosting provider blocks outbound port 25 (some do by default)
- Contact FlashRDP support if needed (port 25 is open by default on all plans)
- Verify Postfix is running:
sudo systemctl status postfix
Authentication Failures
- Check Dovecot logs:
sudo tail -f /var/log/mail.log | grep dovecot - Verify the user password is correct:
sudo doveadm auth test username password - Ensure the SASL socket path matches between Postfix and Dovecot
Certificate Errors
- Verify certificate files exist:
sudo ls -la /etc/letsencrypt/live/mail.yourdomain.com/ - Check certificate expiry:
sudo certbot certificates - Renew if needed:
sudo certbot renew
Why FlashRDP for Mail Server Hosting
FlashRDP VPS plans are purpose-built for self-hosted services like mail servers:
- Clean IP Addresses: Our IPs are not on major email blacklists
- Port 25 Open by Default: No need to request SMTP port unblocking
- Self-Service rDNS: Configure reverse DNS directly from your Service Area > Network tab without needing to open a support ticket
- Additional IPs: Need dedicated IPs for different mail domains? Additional IPv4 addresses are available as an addon at cost
- KVM Virtualization: True hardware isolation ensures consistent performance
- NVMe Storage: Fast I/O for mail spool operations
- Unmetered 1 Gbps Bandwidth: Handle high email volumes without overage charges
- DDoS Protection: Always-on Layer 4 mitigation keeps your mail server online
- No KYC Required: Deploy with 50+ cryptocurrencies. No identity documents needed.
Plans start at $11.99/month. View all VPS plans.
Frequently Asked Questions
Can I run a mail server on a VPS?
Yes, absolutely. A VPS with at least 2 GB RAM and a clean IP address is sufficient for a personal or small business mail server. FlashRDP VPS plans include everything you need: full root access, clean IPs, open port 25, and self-service rDNS configuration.
Is self-hosting email worth it?
For privacy, control, and learning, yes. Self-hosted email gives you zero dependence on third parties, full data ownership, and the ability to create unlimited mailboxes. However, it requires ongoing maintenance (updates, monitoring, backups). For most businesses, a hybrid approach works best: self-host for privacy-critical mail, use a relay for marketing emails.
How do I prevent my emails from going to spam?
Configure all three authentication records (SPF, DKIM, DMARC), set up a matching rDNS/PTR record (configurable from your FlashRDP Service Area under the Network tab), use a clean IP, warm up your sending reputation gradually, and test with tools like mail-tester.com. Following this guide sets up all these layers.
How much resources does a mail server need?
A basic mail server for under 50 users needs about 1-2 GB RAM and 1-2 vCPU. For larger setups with spam filtering (SpamAssassin or Rspamd), webmail, and virus scanning (ClamAV), plan for 4+ GB RAM.
Can I use this setup for bulk email or newsletters?
This guide is for transactional and personal email, not mass marketing. For bulk email, consider using a dedicated email relay service (Amazon SES, Mailgun, Postmark) alongside your mail server. Using your primary mail server for bulk sends risks blacklisting your IP.
Do I need a static IP for a mail server?
Yes. All FlashRDP VPS plans include a dedicated static IPv4 address, which is essential for consistent email delivery and proper rDNS configuration. If you need additional IPs for multiple domains, these can be added as an addon.
How do I configure rDNS/PTR on FlashRDP?
Log in to your FlashRDP client area, navigate to your VPS service, and go to the Network tab. You can set your reverse DNS hostname directly from there without needing to contact support.

Rohan
Operations Manager & Founder
Operations Manager at FlashRDP. With 5+ years in cloud infrastructure, Rohan specializes in KVM virtualization, network security, and building privacy-focused hosting solutions for professionals worldwide.




