Take the 2-minute tour ×

We are in the process of switching our email from a locally hosted server to Google apps. We have a lot of users and I'd like to be able to switch them over one at a time so I don't get inundated with tech support calls.

On a separate server I installed postfix and added this line to main.cf:

relayhost = []

(Where is our internal mail server).

This works fine, all mail sent through postfix get sent to the internal mail server like it should.

However, I also want the same mail to be sent to Google apps. I added this line to main.cf:

relayhost = [aspmx.l.google.com]

But instead of sending to both servers, Postfix only sends to the last one listed.

Is there a simple solution to this? I don't mind using a different SMTP program or whatever, but I don't want to have to create mappings for each and every user we have.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Ditch postfix and use exim. Create two routers and a transport like so

begin routers

driver = manualroute
route_data =
transport = OutboundSMTP
unseen = true

driver = manualroute
route_data = aspmx.l.google.com
transport = OutboundSMTP

begin transports

driver = smtp

unseen = true causes processing to continue after the first router

share|improve this answer
Thanks, this did it. –  Tim Oct 14 '10 at 19:44
Use Exim as Brent describes instead of Postfix. Worked for me! –  Max Mouse Nov 22 '13 at 12:59

totally quick, unresearched answer from memory, but I think procmail (is it still around?) can do this sort of thing.

share|improve this answer

it's normal. the second will override the first. the postfix configuration is var=value. a second var definition will override the first, not update by appending the new value. you can't easily do this with postfix. i propose two solutions:

solution 1: install two postfix services on the box. one configure it on port 2526 and set it up with relayhost=yourhost, the other on port 2527 with relayhost=google. use a simple event based program for listening on port 25 and forwad the traffic to both postfix instances (you may find something already written, maybe you can use relayd if you're on BSD unix). there's also a TEE plugin somewhere in iptables devel for packet copying but i'm not familiar with. i don't really like this solution

solution 2: on your relayhost configure store&forward. this is more complicated (configuration wide) than the first but since your migration procedure is user based ...

  1. rewrite user@domain to user-store@domain
  2. define user-store@domain as alias for user@domain,user@local.domain
  3. define transport: for user@domain to be google.
  4. define transport for user@local.domain to be virtual:

i used this mechanism once and it seemed to work. however... i'm not sure if google will accept emails for the domain if you didn't set MX to google servers so this can be useless. you should check that.

share|improve this answer

Your Answer


