Blocking ISP : use external SMTP
If your ISP restrict the use of smtp port (25), you can't send any email from your server. To fix this, you may :
- Change for another ISP 😁
- Use an external smtp relay. That's what we'll discuss here.
However, you need another smtp provider. Put the necessary credentials to access this mail account in "/etc/mail/secrets" :
# echo "secret_id user:passphrase" > /etc/mail/secrets
Make sure permissions are appropriate, you don't want everyone to know your password :
# chmod 640 /etc/mail/secrets # chown root:_smtpd /etc/mail/secrets
Then, edit "/etc/mail/smtpd.conf" so outgoing messages go throught external mail server :
... table secrets "/etc/mail/secrets" ... listen on all... ... action "relay" relay host smtp+tls://secret_id@smtp.example.com \ auth <secrets> mail-from "@athome.tld" ... match from any for any action "relay"
Some details :
- "table secrets ...": file where credentials to auth on external server are stored.
- "action "relay" relay ..." : new action so outgoing messages through external server. Edit smtp.example.com according to your mail provider.
- "smtp+tls ..." : Which protocol is used to communicate with external server.
- "mail-from "@athome.tld"" : It is important to show your messages comes from YOUR server, not the relay.
In the end, reload smtpd.
rcctl restart smtpd