To configure Postfix to send emails using an external SMTP server (also known as a "smarthost"), you will need to perform the following steps:
/etc/postfix/main.cf
, and add the following line, replacing <smarthost>
with the hostname or IP address of the external SMTP server:relayhost = <smarthost>:587
<username>
and <password>
with your login credentials:smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:<username>:<password>
Save the changes to the configuration file and exit the text editor.
Restart Postfix to apply the changes:
systemctl restart postfix
sendmail
command:echo "Test message" | sendmail <recipient>