0

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 = [1.2.3.4]

(Where 1.2.3.4 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.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
Tim
  • 3
  • 2

3 Answers3

1

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

begin routers

OurServer:
driver = manualroute
route_data = 1.2.3.4
transport = OutboundSMTP
unseen = true

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

begin transports

OutboundSMTP:
driver = smtp

unseen = true causes processing to continue after the first router

brent
  • 3,521
  • 3
  • 26
  • 37
0

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

0

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.

user237419
  • 1,653
  • 8
  • 8