Postfix Smarthost
Configuration
Deliver all emails sent from your Postfix server through the MXGate smarthost (with SASL authentication and TLS). Works on Ubuntu, Debian, CentOS, RHEL and other Linux distributions.
- Root or sudo access
- Postfix installed and running
- SMTP username and password created from MXGate panel
- libsasl2-modules and sasl2-bin packages (usually installed by default)
Postfix Configuration in 6 Steps
Backup main.cf File
Take a backup of the Postfix configuration file just in case:
Configure main.cf
Edit the Postfix main configuration file. Add the following settings to the end of the main.cf file:
Create SASL Password File
Create the password file containing SMTP authentication credentials:
TLS/SSL Certificate Settings
Set the CA certificates path according to your distribution for TLS encryption:
Reload Postfix Configuration
Reload Postfix to apply configuration changes:
Testing and Verification
Test if the configuration is working:
Common Errors
How do I fix the "SASL authentication failed" error in Postfix?
Check the username/password. Verify the mapping with the command below, then re-run the postmap command and check the file permissions (600, root:root):
sudo postmap -q [smtp.mxgate.com.tr]:587 /etc/postfix/sasl_passwd
Why does Postfix throw an "Unable to verify certificate" error?
Ensure the CA certificate file is in the correct path. Alternatively you can relax TLS verification (not recommended):
smtp_tls_security_level = may
Why does Postfix return a "Connection refused / timed out" error?
The firewall (ufw, firewalld, iptables) may not allow outbound access to port 587. Also ensure your hosting provider does not block SMTP ports.
How do I resolve the "Relay access denied" error in Postfix?
Ensure your server IP is whitelisted in the MXGate panel and that the authentication credentials are correct.
- main.cf:
/etc/postfix/main.cf - Log:
/var/log/mail.log - CA:
/etc/ssl/certs/ca-certificates.crt
- main.cf:
/etc/postfix/main.cf - Log:
/var/log/maillog - CA:
/etc/pki/tls/certs/ca-bundle.crt
Need help?
If you get stuck, our 24/7 support team is here. Let's complete your Postfix configuration together.