LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Postfix how to prevent delivering to local (https://www.linuxquestions.org/questions/linux-newbie-8/postfix-how-to-prevent-delivering-to-local-4175602862/)

linuxdistro 03-30-2017 01:33 PM

Postfix how to prevent delivering to local
 
Hello
I have postfix setup as an MTA and it's only doing the sending.
It's set up to allow some hosts to relay emails to the outside world.

The hostname of the postfix, let's say is post.can.com
And there's a local user named john on this box
John's email john@can.com is hosted at google mail

The issue is that when the host tries to send mail to say john@can.com, instead of sending to John's google email, it sends locally.


Postfix Configuration:
Quote:

myhostname = post.can.com

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mydomain = can.com

myorigin = can.com

Is there a way to make it prevent sending this locally and have it use the mx record for the domain so it can be sent to google mail?

I've tried removing $mydomain from mydestination but it would reject relaying from allowed hosts.

bathory 04-01-2017 08:37 AM

Hi,

I'm not a postfix expert, but I think it can be done using transport maps.
Add in main.cf (if not already there) the line:
Code:

transport_maps = hash:/etc/postfix/transport
Open/edit the file /etc/postfix/transport and use:
Code:

john@can.com smtp:[aspmx.l.google.com]
Of course you should use the appropriate google smtp server above. If you want this to happen for all your users, then omit the "john@" part.

An finally rebuild transport_maps and reload postfix:
Code:

postmap /etc/postfix/transport
postfix reload


linuxdistro 04-02-2017 08:37 PM

That worked, thanks!


All times are GMT -5. The time now is 03:03 PM.