Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a test postfix (2.6.6) server configured to intercept all outbound emails and store them locally, so that the devs can test email functionality of client apps without spamming the world.

The server accepts mail for @local.test, and accepts mail from servers defined in a cidr mapping table: OK OK

The test server has 5 virtual users (test1@local.test, test2@local.test etc.), and postfix is configured as both the MTA and LDA as described in the VIRTUAL_README.

I can configure the server to redirect all relayed mail to one of the local accounts using recipient canonical classes/maps, as described in this blog post.

recipient_canonical_classes = envelope_recipient
recipient_canonical_maps = regexp:/etc/postfix/recipient_map

/./ test1@local.test

But what I'd like to do now is redirect mail based on the ip address of the source server sendng the mail, so for example: -> test1@local.test -> test2@local.test -> test3@local.test

There's only a few of these, so I don't need any dynamic mapping, just a simple config file would do.

Anyone have any clues how I could do this?


share|improve this question
you could try check_client_access and in the map file use something like REDIRECT test1@local.test – Gryphius Jun 16 '13 at 8:36
Awesome - exactly what I needed - just so many options to this thing I couldn't find the right one! So don't need the recipient classes / maps any more either. Thanks heaps! – Barney Jun 16 '13 at 9:24

convert solution from comment to CW

Postfix SMTP server access table [man page] support REDIRECT feature

REDIRECT user@domain
          After the message is queued, send the message to  the  specified
          address instead of the intended recipient(s).

          Note:  this  action  overrides  the FILTER action, and currently
          affects all recipients of the message.

Combine this feature with check_client_access will be solution to your problem, i.e. REDIRECT test1@local.test
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.