Postfix relaying question

Mike Lovell toelovell at
Mon Jun 25 21:45:56 MDT 2007

Michael L Torrie wrote:
> On Mon, 2007-06-25 at 13:17 -0600, Kirk Cerny wrote:
>> I have not rried it but, you could use a regex in the virtual file to
>> match all after all the other matches, and forward them to there
>> desired location.
>> # virtual file
>> /^(.*)@(.*)$/    $1@$2
> Nope that won't work.  I need to forward mail to a particular MX, not an
> e-mail address.  in other words blah at gets forwarded to SERVER
> B, which takes care of blah at  The e-mail address it is going to
> is still blah at
> A common use case for this type of things is a SMTP server that accepts
> mail, then, based on the address (and/or the domain) relays the mail on
> to the server that handles those addresses.  For example, a corporation
> may have a corporate e-mail server that sends mail off to regional
> servers based on some criteria that could even be something to do with
> the username part.
> In my case I'm using Google Apps for domains, but I want my server to
> accept all the mail first, processing the accounts that it has, and then
> sending whatever it doesn't want to deal with off to google's MX where
> the rest of my users are managed.
> I'll keep researching.
> Michael
> /*
> PLUG:, #utah on
> Unsubscribe:
> Don't fear the penguin.
> */
If you are just wanting to relay mail to specific address, you can do it 
by just using the email aliases file (most likely /etc/aliases). I 
currently use postfix in a manner similar to this. I manage a postfix 
server which has a lot of local mailboxes but also relays mail for some 
accounts on to a hosted exchange system. I am guessing that you have 
individual account on the google side in which case you could simply do 
something like

joe: joe at

in /etc/aliases. This will forward the mail that is received for joe on 
to the gmail account for joe and, depending on the configuration on the 
google side, the to address would not be changed. I'm not quite sure if 
this is what you are looking for. Good luck either way.

Mike Lovell

More information about the PLUG mailing list