Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

127.0.0.0/8 OK
10.0.0.0/24 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:

10.0.0.1 -> test1@local.test
10.0.0.2 -> test2@local.test
10.0.0.3 -> 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?

Thanks,

share|improve this question
1  
you could try check_client_access and in the map file use something like 10.0.0.1 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

1 Answer 1

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.

10.0.0.1 REDIRECT test1@local.test
share|improve this answer

Your Answer

 
discard

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.