How to Setup SMTP Relay on a VPS with ZeptoMail
Configure Postfix on Ubuntu to relay all outgoing emails through ZeptoMail. Fix email delivery issues on VPS servers running CloudPanel or similar.
If you’re running WordPress (or any app) on a VPS, sending email directly from the server is unreliable. Most VPS providers block port 25, and even when they don’t, outgoing mail from a bare server lands in spam. The solution is a relay: route all outbound email through a dedicated mail service.
I use ZeptoMail by Zoho. They give you 10,000 free emails to start with, and after that it’s $2.50 per 10,000 emails (credits valid for 6 months). No monthly subscription, just pay-as-you-go. Delivery has been reliable for me across multiple servers.
Step 1: Configure ZeptoMail
Sign up at ZeptoMail, buy a credit pack, and add your domain. They’ll ask you to add SPF, DKIM, and CNAME records in your DNS. Once verified, go to Configuration to find your SMTP hostname, username, and password — you’ll need these next.
Step 2: Install Postfix
On Hetzner, Postfix is pre-installed. On a fresh Ubuntu server:
sudo apt update
sudo apt install -y mailutils
Choose Internet Site during setup and enter your domain (e.g., yourdomain.com).
Step 3: Configure Postfix to use the relay
Edit /etc/postfix/main.cf:
sudo nano /etc/postfix/main.cf
Add at the end:
# ZeptoMail SMTP relay
relayhost = [smtp.zeptomail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
Step 4: Store credentials
Create /etc/postfix/sasl_passwd:
sudo nano /etc/postfix/sasl_passwd
Add your ZeptoMail credentials:
[smtp.zeptomail.com]:587 yourusername:yourpassword
Generate the hash database and lock down the file:
sudo postmap /etc/postfix/sasl_passwd
sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Step 5: Fix the sender address
Without this, ZeptoMail will reject emails sent by WordPress or other apps because the “from” domain doesn’t match your verified domain.
Create /etc/postfix/sender_canonical:
/.+/ noreply@yourdomain.com
Create /etc/postfix/smtp_header_checks:
/From:.*/ REPLACE From: noreply@yourdomain.com
Or with a display name:
/From:.*/ REPLACE From: Your Name <noreply@yourdomain.com>
Use an email address on the domain you verified in ZeptoMail.
Step 6: Check /etc/mailname
If your VPS hostname is a subdomain (e.g., cloud.yourdomain.com), Postfix may try to use that as the sending domain. Fix it:
sudo nano /etc/mailname
Set it to just the root domain:
yourdomain.com
Step 7: Reload Postfix
sudo postfix reload
Step 8: Test
echo "test message" | mail -s "test subject" you@example.com
Check the log to confirm delivery:
tail -f /var/log/mail.log
A successful send looks like:
postfix/smtp: status=sent (250 Message received)
Once this is working, every app on the server (WordPress, cron job notifications, system emails) will route through ZeptoMail automatically.
Alternatives to ZeptoMail
ZeptoMail works well for me, but there are other options depending on your volume and budget:
- Amazon SES — $0.10 per 1,000 emails. Cheapest at scale, but you have to manage reputation and setup yourself. Good if you’re already on AWS.
- Postmark — $15/month for 10,000 emails. Known for fast delivery and excellent deliverability. More expensive but hands-off.
- Resend — Free tier available, $20/month for more. Modern API, popular with developers. Relatively new.
- Brevo (formerly Sendinblue) — Starts at $9/month. Combines transactional and marketing email if you need both.
For a small VPS running a few WordPress sites, ZeptoMail’s pay-as-you-go model is hard to beat on price. If you send more than 50,000 emails/month, Amazon SES becomes the cheaper option.