LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-29-2011, 04:53 AM   #1
stuartsjb
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Question Postfix -- selective forwards for external domains


Hello,

I would like Postfix to rewrite certain recipient addresses, for an external domain.

That is, I have a web application that sends email to @company.com -- which is a domain that is not hosted on my server.

I want to intercept and rewrite certain addresses in the 'to' field of outgoing email:
stuart@company.com --> stuart@abc.com
sheila@company.com --> ssmith@abc.com

... but I want every other email to be delivered as normal, through the mail gateway:
justin@company.com --> justin@company.com
...
@company.com --> @company.com

I don't think I can do this using virtual domains -- I could do the first part, but I can't see how I could then say, "for everything else, deliver as normal", as I don't need a normal catch-all.

Any ideas?

Many thanks,
Stuart.
 
Old 11-29-2011, 12:14 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
the rewrite tables will target specific email addresses. you should be familiar with this.
 
1 members found this post helpful.
Old 11-29-2011, 02:18 PM   #3
stuartsjb
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thank you very much, Berhanie -- this allowed me to piece together the jigsaw, without thinking that I was looking in the wrong place! For reference for anyone in a similar boat, I've done the following:

Created the file /etc/postfix/canonical, and put the following lines in it:
And run sudo postmap /etc/postfix/canonical to create the hashed table.

Then added the following line to /etc/postfix/main.cf:
Code:
canonical_maps = hash:/etc/postfix/canonical
And run sudo postfix reload.

A quick test seems to suggest that this does the trick, though I'll check more thoroughly in the morning. Hurrah -- thanks again!

Stuart.
 
Old 11-29-2011, 05:26 PM   #4
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
ok, if that works for you. canonical has specific semantics, which is to make locally significant addresses, such as bob@localhost.localdomain, into something meaningful to the rest of the world.

correction: i described the generic map, not canonical. generic is used to transform localhost.localdomain into a valid domain. canonical is used to transform valid email addresses, e.g. bsmith@example.com, into a domain-specific standard form,
e.g. bob.smith@example.com.

Last edited by Berhanie; 11-30-2011 at 02:53 AM.
 
1 members found this post helpful.
Old 11-30-2011, 09:20 AM   #5
stuartsjb
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
That's handy to know -- thanks for that! The method I described does seem to work for me -- do you happen to know which table I should have used though, to align with standard use?
 
Old 11-30-2011, 09:52 AM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
i would first try virtual alias. i'd have to look at the man pages again to make sure.

as you see, there are several ways of doing it, but if i were working on an unfamiliar postfix system, looking for the place where you put these aliases, that's the map i'd check first.
 
1 members found this post helpful.
Old 01-08-2012, 10:56 AM   #7
stuartsjb
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Mmmm, having now read around this some more, I think you're right that the mapping I was using should ideally have sat in the virtual alias file, which is handy to know for the future. Many thanks again for your help, Berhanie!
 
  


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
domain alias email and acutal forwards in postfix nici0306 Linux - Software 1 07-06-2010 10:03 PM
postfix not delivering mail to external domains javier_ccs Linux - Server 2 05-23-2009 12:21 PM
Problems to send messages using Postfix on Debian Sarge to external domains gaiotto Debian 2 08-02-2006 03:35 AM
Postfix upgrade from 1.x to 2.0.19 can't relay to external domains issinflight Linux - Software 0 04-19-2004 10:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:47 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
Open Source Consulting | Domain Registration