Setting up relayhost for postfix on OSX (with ssl and authentication)
Ok several co workers asked me how to make the command line mail tool use a proper mailserver under osx. The problem is that it sends mails directly which will not be accepted by most of the mailservers.
If you only want to send your mail plaintext over a mailserver and not use any authentication you just have to add this line to your /etc/postfix/main.cf:
relayhost = gorn.ch
If your mailserver allows SSL encryption you should also add the following lines:
smtp_sasl_auth_enable = yes smtp_sasl_security_options =
Now finally if your mailserver requires a login you need some more steps to do. First add the following line to your main.cf:
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
Now create a file called /etc/postfix/sasl_passwd make sure it's only readable by root because you will have to put in your password there the syntax looks like this:
gorn.ch username:password
Finally run this and you should be good to go. Send a mail over the commandline to make sure it works. :)
sudo postmap hash:/etc/postfix/sasl_passwd