-   Linux - Newbie (
-   -   Postfix how to prevent delivering to local (

linuxdistro 03-30-2017 01:33 PM

Postfix how to prevent delivering to local
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
And there's a local user named john on this box
John's email is hosted at google mail

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

Postfix Configuration:

myhostname =

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

mydomain =

myorigin =

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


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

transport_maps = hash:/etc/postfix/transport
Open/edit the file /etc/postfix/transport and use:
Code: smtp:[]
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:

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.