How to Linux smtp relay
Published October 20, 2024 · Updated July 18, 2026 · Guides & Tutorials
On a Linux server, sending email reliably usually means configuring a relay — pointing your system's mail through an authenticated SMTP smart host instead of trying to deliver directly. Direct delivery from a Linux box tends to land in spam or get blocked outright. Here is how to set up a Linux SMTP relay the dependable way.
Why relay instead of sending directly
A fresh Linux server has no sending reputation, its IP may be on a shared or blocked range, and port 25 is often filtered. Relaying through an authenticated SMTP smart host solves all three: you inherit a trusted IP, proper authentication, and a port that is not blocked.
How to configure a relay with Postfix
- Install Postfix (the most common Linux mail agent).
- In
/etc/postfix/main.cf, setrelayhost = [your-smtp-host]:587. - Enable SASL authentication and point it at a credentials file with your SMTP username and password.
- Turn on TLS so the connection is encrypted.
- Reload Postfix and send a test with
sendmailormail.
chmod 600), and never expose the relay to the public internet as an open relay. Restrict who can send through it.Point your Linux server at a dedicated SMTP
Dedicated IP, port 587, and SPF/DKIM/DMARC ready — the reliable smart host your Postfix relay needs. From $39.99/mo.
Frequently asked questions
How do I set up an SMTP relay on Linux?
Install Postfix, set relayhost to your SMTP smart host on port 587, enable SASL authentication and TLS, then reload and test.
Why not send email directly from Linux?
Fresh servers lack reputation, may sit on blocked IP ranges, and port 25 is often filtered. Relaying through an authenticated smart host is far more reliable.
What smart host should I use?
A dedicated SMTP with its own IP and full authentication — it gives your Linux relay trusted delivery and no daily caps.