Configure Postfix to relay mail through another SMTP

Configuration

Let's suppose the smtp server at which you want to authenticate is "smtp.example.com" and your username is "user@example.com" with password "password".
You'll just have to run the following commands:
postconf -e 'relayhost = smtp.example.com'
postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
echo "mail.qaniklab.it   user@example.com:password" > /etc/postfix/sasl_passwd
/etc/init.d/postfix restart 

Monitoring

To monitor the sending queue for errors just run:
postqueue -p
and look at the files:
less /var/log/mail.log
less /var/log/mail.err

Visit the website of the company behind these tutorials: www.qaniklab.it