To use Postfix to securely Relay or Smart Host mail to MailShark, please perform the following:

1. Install Postfix, Cyrus-SASL, and the necessary support stuff including OpenSSL

2. Your /etc/postfix/main.cf file needs to have lines like this:

relayhost = [mail.foo.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_type = cyrus
smtp_use_tls = yes


Special notes:

  • Don't forget the square brackets around the relay host name, or your Postfix installation will do an MX lookup on the name, then connect to the mailserver that comes back from the MX lookup.
  • If your ISP doesn't block port 25 then you don't need to specify port number 587 in the relayhost line.

3. Create a password file by editing /etc/postfix/sasl_passwd and adding a line like this:

[mail.foo.com] username:password

Again, don't forget the square brackets.

4. Convert the password file to a DB file by executing

postmap /etc/postfix/sasl_passwd

5. Use postfix reload to reinitialize postfix with your new main.cf file.

Test your mail and make sure it works.