Skip to main content
You need your SMTP username, password, and relay hostname from your mySMTP setup email.

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

Configure the smart host

1

Edit main.cf

Open /etc/postfix/main.cf in your editor and add or update these lines:
Replace relayxx.mysmtp.com with your actual relay hostname.
2

Create the SASL password file

Create /etc/postfix/sasl_passwd with this content:
Replace 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 the mail or sendmail command:
If your system does not have the mail command, install mailutils (Debian/Ubuntu) or mailx (RHEL).
Check the mail log for delivery status:
Look for a successful connection to your relay hostname and a status=sent entry.

Troubleshooting

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.
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.
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.
Make sure the sender address uses a domain authenticated for your mySMTP account. See DNS settings quick explainer.
For more error codes, see Common SMTP errors.