August 25, 2026 · by Alex M.
If you run a website, a web application, or an online store, transactional emails — order confirmations, notifications, password resets — are essential. Relying on external email services can be limiting and costly. The solution? Your own mail server, built with Postfix, the most popular Mail Transfer Agent (MTA) in the Linux world.
In this guide you'll learn how to install and configure Postfix on a NVMe VPS or SSD VPS, step by step — from installation through to testing email delivery.
Postfix is an open-source SMTP server — fast, secure, and easy to configure. It accepts messages from applications or users and delivers them either locally or over the internet via the SMTP protocol.
Key advantages:
- Easy to install on any Linux distribution (Ubuntu, Debian, CentOS, AlmaLinux)
- High performance even on limited resources
- Native integration with Dovecot, SpamAssassin, OpenDKIM
- Large community and excellent documentation
⚠️ Important note: This guide covers configuring Postfix as an outbound MTA only. A full mail server (with mailboxes, IMAP) also requires Dovecot, which will be covered in a separate article.
Before you begin, make sure you have:
Check whether port 25 is open:
telnet smtp.gmail.com 25
If the connection succeeds, you're ready to proceed.
sudo apt update && sudo apt upgrade -y
sudo apt install postfix -y
During installation, an interactive menu will appear. Select:
- Configuration type: Internet Site
- System mail name: your domain (e.g. example.com)
After installation, verify the status:
sudo systemctl status postfix
You should see active (running).
The main configuration file is located at /etc/postfix/main.cf. Open it with a text editor:
sudo nano /etc/postfix/main.cf
Ensure the following directives are set correctly:
# Server identity
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
# Listening interfaces
inet_interfaces = all
inet_protocols = ipv4
# Local destinations
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# Trusted networks
mynetworks = 127.0.0.0/8
# Mailbox format
home_mailbox = Maildir/
# Limits
message_size_limit = 52428800
Save the file (Ctrl+O, Enter, Ctrl+X) and restart Postfix:
sudo systemctl restart postfix
Without TLS, your emails can be intercepted in transit. If you already have an SSL certificate (obtained with Let's Encrypt or from CLIQHOST), add the following to main.cf:
# TLS for incoming connections
smtpd_tls_cert_file = /etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/example.com/privkey.pem
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
# TLS for outgoing connections
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_security_level = may
Restart Postfix again after these changes:
sudo systemctl restart postfix
Without correct DNS records, your emails will land in spam. Three types of records are required:
Add a TXT record to your domain:
name: @ type: TXT value: "v=spf1 ip4:YOUR_SERVER_IP mx ~all"
Replace YOUR_SERVER_IP with your VPS IP address.
Install OpenDKIM:
sudo apt install opendkim opendkim-tools -y
Generate the keys:
sudo mkdir -p /etc/opendkim/keys/example.com
sudo opendkim-genkey -b 2048 -d example.com -D /etc/opendkim/keys/example.com -s mail -v
sudo chown -R opendkim:opendkim /etc/opendkim/keys/
The contents of the mail.txt file from the generated directory must be added as a TXT record in DNS:
name: mail._domainkey.example.com type: TXT value: (contents of mail.txt)
Configure /etc/opendkim.conf and link OpenDKIM to Postfix via socket:
MilterProtocol 6
Syslog yes
UMask 002
Domain example.com
KeyFile /etc/opendkim/keys/example.com/mail.private
Selector mail
In main.cf, add:
milter_protocol = 6
milter_default_action = accept
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
Restart both services:
sudo systemctl restart opendkim postfix
Add a TXT record:
name: _dmarc type: TXT value: "v=DMARC1; p=quarantine; rua=mailto:[email protected]"
sudo apt install mailutils -y
echo "This is a test email" | mail -s "Postfix Test" [email protected]
sudo tail -f /var/log/mail.log
Look for the line status=sent — if it appears, the email was sent successfully.
Use mail-tester.com — send an email to the address generated by the site and you'll receive a score from 1 to 10. Aim for at least 8/10.
| Problem | Likely Cause | Solution |
|---|---|---|
| Emails land in spam | SPF/DKIM/DMARC missing or wrong | Reconfigure DNS records |
Connection refused on port 25 |
Port blocked by provider | Contact CLIQHOST support |
Relay access denied |
mynetworks too restrictive |
Add the application IP to mynetworks |
| TLS handshake failed | Expired or misconfigured SSL cert | Renew or verify the certificate |
An unprotected mail server quickly becomes a spam source. A few essential measures:
mynetworks should only contain your trusted networkssmtpd_client_message_rate_limit/var/log/mail.log and /var/log/mail.errsudo apt upgrade postfixIf you need a managed solution, server management services from CLIQHOST include configuration and monitoring of mail servers. For heavier workloads, our managed dedicated servers offer the ideal foundation.
Postfix is an excellent choice for sending email from your own Linux server. With the correct configuration of TLS, SPF, DKIM, and DMARC, your messages will land in the inbox — not in spam.
The keys to success are:
- A VPS with a clean IP (no spam history)
- Complete and accurate DNS records
- Continuous log monitoring
If you're looking for a stable infrastructure on which to run Postfix, explore NVMe VPS plans from CLIQHOST — high performance, clean IPs, and technical support available around the clock. For any additional questions, our team is always ready to help.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."