Before you start
Have these details ready:Use the exact relay hostname from your setup email.
relayxx.mysmtp.com is only an example.Install required packages
- Debian / Ubuntu
- RHEL / CentOS / Rocky
Configure the smart host
1
Edit main.cf
Open Replace
/etc/postfix/main.cf in your editor and add or update these lines:relayxx.mysmtp.com with your actual relay hostname.2
Create the SASL password file
Create Replace
/etc/postfix/sasl_passwd with this content:relayxx.mysmtp.com, username, and password with your actual values.3
Hash the password file
Run:This creates
sasl_passwd.db. For security, restrict permissions on both files:4
Restart Postfix
Test the connection
Send a test email using themail or sendmail command:
If your system does not have the
mail command, install mailutils (Debian/Ubuntu) or mailx (RHEL).status=sent entry.
Troubleshooting
Authentication failed (SASL authentication failed)
Authentication failed (SASL authentication failed)
Double-check the username and password in
/etc/postfix/sasl_passwd. Run sudo postmap /etc/postfix/sasl_passwd again after any change, then restart Postfix.Connection timed out
Connection timed out
Check that outbound traffic on port 587 is allowed by your firewall. Try port 2525 if port 587 is blocked:Update the port in
/etc/postfix/sasl_passwd as well, then run sudo postmap /etc/postfix/sasl_passwd and restart Postfix.TLS handshake failed
TLS handshake failed
Confirm
smtp_tls_security_level = encrypt is set in main.cf. Some older systems may need smtp_tls_wrappermode = yes for port 465, but mySMTP uses STARTTLS on port 587.Relay access denied
Relay access denied
Make sure the sender address uses a domain authenticated for your mySMTP account. See DNS settings quick explainer.
.png?fit=max&auto=format&n=-Uw4rR8wfyv_xkzc&q=85&s=898bb0b43b6c9dce61441f46ac9ac860)