Blogs
WordPress 7.0: 10 New Features and Improvements
April 10, 2026Hosting email on your own server gives you full control, privacy, and branding (e.g., you@yourdomain.com). While it requires careful setup, modern tools make it achievable even for small businesses and developers.
This guide walks you through how to set up your email hosting on your own server, from planning to installation, security to DNS configuration and everything in between..
- What You Need Before You Start?
-
How to Set Up Email Hosting on Your Own Server? (Step-by-Step Guide)
- Step 1: Understand Core Email Components
- Step 2: Set Your Server Hostname Correctly
- Step 3: Install the Mail Server (Postfix)
- Install Postfix
- Configuration Prompts
- Step 4: Install Dovecot (IMAP & POP3)
- Step 5: Create Email Users
- Step 6: Configure DNS Records (CRITICAL)
- 1. MX Record
- 2. A Record
- 3. SPF Record
- 4. DKIM (Highly Recommended)
- 5. DMARC Record
- Step 7: Enable TLS Encryption (Let’s Encrypt)
- Step 8: Install Spam Protection
- SpamAssassin
- Step 9: Add Webmail (Optional but Useful)
- Install Roundcube
- Step 10: Test Email Functionality
- Send Test Email
- Use External Tools
- Step 11: Secure Your Email Server
- Firewall
- Fail2Ban
- Common Mistakes to Avoid
- Conclusion
What You Need Before You Start?
Before you set up email hosting on your own server, make sure you have:
1. A Server
- VPS or Dedicated Server (DigitalOcean, AWS EC2, Linode, Hetzner, Vultr)
- Recommended OS: Ubuntu 20.04 or 22.04 LTS
- Minimum: 1 GB RAM, 1 CPU
2. A Domain Name
- Example: example.com
- Access to your DNS management panel
3. A Static IP Address
- Email servers require a static IPv4
- Reverse DNS (PTR record) should be configurable
How to Set Up Email Hosting on Your Own Server? (Step-by-Step Guide)
Here is the step by step process you can use to set up email hosting on your own server.
Step 1: Understand Core Email Components
An email server is made of multiple services working together:
| Component | Purpose | Common Software |
| MTA (Mail Transfer Agent) | Sends & receives mail | Postfix, Exim, Sendmail |
| MDA / IMAP Server | Stores & fetches mail | Dovecot |
| SMTP Submission | Authenticated sending | Postfix |
| Spam Filtering | Spam protection | SpamAssassin, Rspamd |
| Webmail | Browser-based email | Roundcube |
| Encryption | Secure transport | TLS / SSL (Let’s Encrypt) |
Recommended stack:
Postfix + Dovecot + SpamAssassin + Roundcube
Step 2: Set Your Server Hostname Correctly
Your server hostname must match your domain.
sudo hostnamectl set-hostname mail.example.com
Edit /etc/hosts:
127.0.0.1 localhost
YOUR_SERVER_IP mail.example.com mail
Verify:
hostname
Step 3: Install the Mail Server (Postfix)
Install Postfix
sudo apt update
sudo apt install postfix
Configuration Prompts
- Mail configuration type: Internet Site
- System mail name: example.com
Postfix configuration file:
/etc/postfix/main.cf
Key settings:
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
Restart Postfix:
sudo systemctl restart postfix
Step 4: Install Dovecot (IMAP & POP3)
Dovecot allows users to read emails.
sudo apt install dovecot-imapd dovecot-pop3d
Edit:
/etc/dovecot/dovecot.conf
Ensure:
protocols = imap pop3
Mail location:
/etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
Restart:
sudo systemctl restart dovecot
Step 5: Create Email Users
Each Linux user can be an email account.
sudo adduser john
Email address becomes:
john@example.com
Mail stored in:
/home/john/Maildir
Step 6: Configure DNS Records (CRITICAL)
Log into your domain’s DNS panel.
1. MX Record
example.com → mail.example.com
Priority: 10
2. A Record
mail.example.com → YOUR_SERVER_IP
3. SPF Record
v=spf1 ip4:YOUR_SERVER_IP -all
4. DKIM (Highly Recommended)
Install OpenDKIM:
sudo apt install opendkim opendkim-tools
Generate key:
opendkim-genkey -s default -d example.com
Add DKIM TXT record to DNS.
5. DMARC Record
v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com
✔ These records prevent spam and improve deliverability.
Step 7: Enable TLS Encryption (Let’s Encrypt)
Install Certbot:
sudo apt install certbot
Generate certificate:
sudo certbot certonly –standalone -d mail.example.com
Configure Postfix TLS:
/etc/postfix/main.cf
smtpd_tls_cert_file=/etc/letsencrypt/live/mail.example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mail.example.com/privkey.pem
smtpd_use_tls=yes
Restart:
sudo systemctl restart postfix dovecot
Step 8: Install Spam Protection
SpamAssassin
sudo apt install spamassassin spamc
Enable service:
sudo systemctl enable spamassassin
sudo systemctl start spamassassin
Optional but recommended: Rspamd (modern alternative).
Step 9: Add Webmail (Optional but Useful)
Install Roundcube
sudo apt install roundcube roundcube-core
Access via:
https://mail.example.com/roundcube
Users log in with:
- Email: john@example.com
- Password: Linux user password
Step 10: Test Email Functionality
Send Test Email
echo “Test email” | mail -s “Hello” you@gmail.com
Use External Tools
- Mail Tester
- MXToolbox
- Google Postmaster Tools
Check:
- SPF
- DKIM
- DMARC
- Reverse DNS
Step 11: Secure Your Email Server
Firewall
sudo ufw allow 25,465,587,110,143,993,995/tcp
sudo ufw enable
Fail2Ban
sudo apt install fail2ban
Protects against brute-force attacks.
Common Mistakes to Avoid
Missing PTR (reverse DNS)
No SPF/DKIM/DMARC
Open xrelay
Weak passwords
No TLS encryption
Conclusion
Set up your email hosting on your own server to get
- Full control
- No third-party tracking
- Professional branding
- Lower long-term cost
However, it requires ongoing maintenance (updates, monitoring, blacklists). If reliability is more important than control, consider managed email providers like Google Workspace or Zoho Mail. Did this step by step guide on how to set up email hosting on your own server helped you? Share your feedback with us in the comments section below.
Featured Post
Web Hosting for Small Business: Everything You Need to Know
Starting a small business is exciting—but getting your website online can quickly become overwhelming. With so many hosting providers, pricing plans, technical features, and confusing jargon, […]
Web Hosting for Mid-Size Business: Everything You Need to Know
Web hosting is not just “space on a server”, it’s a strategic technology platform that must support performance, security, scalability, compliance, and revenue-critical digital services. For […]
Web Hosting for WordPress: A Comprehensive Guide
Choosing the right web hosting for WordPress site is one of the most important — yet misunderstood — decisions a site owner makes. The hosting you […]