LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-30-2017, 02:33 PM   #1
linuxdistro
LQ Newbie
 
Registered: Jan 2010
Posts: 13

Rep: Reputation: 0
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.
 
Old 04-01-2017, 09:37 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,643

Rep: Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813
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
 
1 members found this post helpful.
Old 04-02-2017, 09:37 PM   #3
linuxdistro
LQ Newbie
 
Registered: Jan 2010
Posts: 13

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


Reply


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 07:00 AM
Postfix not delivering to dovecot for local users (delivering to default user mail) Awalsh Linux - Server 0 07-27-2009 12:13 PM
How to prevent spoofing from Postfix/local part nihal Linux - Security 9 05-06-2009 12:10 PM
How to prevent sendmail from delivering mail to other systems? CBMcArthur Linux - Server 4 08-05-2007 12:37 PM
POSTFIX not delivering? BxBoy Linux - Software 1 06-04-2003 04:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:30 AM.

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