P H O T O N

CONSOLE

Loading

Linux MTA Configuration Guide

Configure Postfix with External SMTP Relay (Smart Host)
Ubuntu • Debian • RHEL • SASL Auth & TLS

Route all Linux server emails, cron job alerts, and system notices through an authenticated external relay host. Bypass cloud provider port 25 blocks and guarantee inbox delivery.

6 min read • Postfix 3.x Tested • Production main.cf
Direct Answer: Postfix Smart Host Configuration

To configure Postfix with an external SMTP smart host relay, edit /etc/postfix/main.cf: set relayhost = [mail.photonrelay.com]:587, enable SASL authentication (smtp_sasl_auth_enable = yes), configure TLS encryption (smtp_tls_security_level = encrypt), add your credentials to /etc/postfix/sasl_passwd, hash it with postmap /etc/postfix/sasl_passwd, and reload Postfix with systemctl restart postfix.

1. Why Route Linux Mail Through a Smart Host Relay?

Hosting providers such as AWS EC2, DigitalOcean, Linode, and Google Compute Engine permanently block outbound TCP port 25 to protect their network IP ranges from botnet spam.

Configuring Postfix as a **Smart Host client** routes all outgoing system notifications, cron logs, and application dispatches over submission **port 587 with STARTTLS**, bypassing cloud firewall blocks cleanly.

2. Installing Required SASL Libraries

# Ubuntu / Debian
sudo apt update && sudo apt install -y postfix libsasl2-modules bsd-mailx

# RHEL / CentOS / Rocky Linux
sudo dnf install -y postfix cyrus-sasl cyrus-sasl-plain mailx

3. Configuring /etc/postfix/main.cf

Append these directives to the bottom of /etc/postfix/main.cf:

# Smart Host Relay Settings
relayhost = [mail.photonrelay.com]:587

# Enable SASL Authentication
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

# TLS / SSL Security Settings
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

4. Setting Up and Hashing /etc/postfix/sasl_passwd

Create /etc/postfix/sasl_passwd and add your authenticated credentials:

# /etc/postfix/sasl_passwd
[mail.photonrelay.com]:587 your_photon_api_key:your_photon_api_secret

Secure the file permissions and compile the lookup database:

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo chmod 600 /etc/postfix/sasl_passwd.db
sudo systemctl restart postfix

5. Testing Dispatch and Inspecting Mail Logs

Send a test message using mailx:

echo "Test message via PhotonRelay" | mail -s "Postfix SmartHost Test" user@example.com

# Watch the live delivery log:
sudo tail -f /var/log/mail.log

Reliable Linux Server Email Delivery with PhotonRelay

Route server alerts with zero port 25 blocks. Get 5,000 free monthly emails and sub-700ms delivery across AWS, DigitalOcean, and GCP.

6. Frequently Asked Questions

Square brackets e.g. [mail.photonrelay.com]:587 instruct Postfix to resolve the destination host directly via DNS A/AAAA records instead of querying for MX records on the hostname.

Restrict access by running 'chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db' and setting owner to root. This prevents non-root system users from viewing plain text API secrets.

Inspect the mail log using 'tail -f /var/log/mail.log' (Ubuntu/Debian) or 'journalctl -u postfix -f' (RHEL/CentOS). Look for 'status=sent (250 OK: queued as ...)'.