Since my ISP blocks port 25, preventing me from running my own in-house email, I relay all my in-house emails and notifications generated from various components though the ISP email servers. This allows me to have internal components send messages to my in house server on 25 and those messages are relayed out to the ISP for delivery.
This setup works on Ubuntu 12.04 and 14.04
nano /etc/postfix/main.cf
Add the following (obviously replace the domain names and IP ranges with your own.)
myhostname = server.mydomain.local alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = server.myisp.com, localhost relayhost = [server.myisp.com]:587 mynetworks = 192.168.10.0/24 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all #fix for some isp configs being stupid. smtp_discard_ehlo_keyword_address_maps = hash:/etc/postfix/busted-servers smtp_connection_cache_on_demand = no smtp_discard_ehlo_keywords = pipelining,silent-discard ### Relay client Auth smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
Next we need to give the server the credentials it needs to perform the relay.
Create the password file:
nano /etc/postfix/sasl_passwd
Add the following line for your ISP.
[server.myisp.com]:587 username@mydomain.com:mypassword
Create the mailname file and change what is there
Echo mydomain.com >> /etc/mailname
Change permissions and run the mapping command.
Chmod 600 sasl_passwd Postmap hash:/etc/postfix/sasl_passwd
That’s it. Send some test messages to your internal server and it should get delivered.
“Change permissions and run the mapping command” uses upper case in command but needs lower case.