Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-30-2017, 01:33 PM   #1
LQ Newbie
Registered: Jan 2010
Posts: 16

Rep: Reputation: Disabled
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.
Old 04-01-2017, 08:37 AM   #2
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,189
Blog Entries: 1

Rep: Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050Reputation: 2050

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
1 members found this post helpful.
Old 04-02-2017, 08:37 PM   #3
LQ Newbie
Registered: Jan 2010
Posts: 16

Original Poster
Rep: Reputation: Disabled
That worked, thanks!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Postfix sending mail to local mailboxes in a virtual-host setup nap_blownapart Linux - Server 3 07-24-2012 06:00 AM
Postfix not delivering to dovecot for local users (delivering to default user mail) Awalsh Linux - Server 0 07-27-2009 11:13 AM
How to prevent spoofing from Postfix/local part nihal Linux - Security 9 05-06-2009 11:10 AM
How to prevent sendmail from delivering mail to other systems? CBMcArthur Linux - Server 4 08-05-2007 11:37 AM
POSTFIX not delivering? BxBoy Linux - Software 1 06-04-2003 03:54 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration