Setup Mail Relay on postfix based on recepient domain
You will need to do all of this as root, so either sudo or elevate to a root shell.
- Create a file that will contain the domains that will be processed by another server. I used
/etc/postfix/bysender. - Open the file
bysender, add the following information:@example.com [outbound.thirdparty.server.com]- On the left
@example.comis the domain that you want to have its messages forwarded (relayed) to the outside server - The right
[outbound.thirdparty.server.com]is the server that you want to relay messages to, and yes you need the brackets - By the way: You could have one particular user’s messages relayed to a different outside mail server by just putting in the entire e-mail address on the left side
- On the left
- Save and Close the
bysenderfile. - Now we need to hash/map the
bysenderfile so that Postfix can use it. Run the following command:postmap /etc/postfix/bysender - Now open your Postfix
main.cfand insert the following:sender_dependent_relayhost_maps = hash:/etc/postfix/bysender- Update the file path if needed
- Now you need to restart Postfix, run the following command:
service postfix restart- This assumes Ubuntu’s Service Command
Comments
Post a Comment