2

I have mail server setup to use postfix and cyrus imapd + ldap for mail lookups.

Now I would like to specify that for particular address (e.g. someuser@domain.com) instead of delivering mail to mailbox it gets passed to script (ruby script to be more precise). I need this functionality since I would like to have mails passed to particular address to end up on our redmine server. How to do this?

Currently I have in main.cf:

...
mydestination = $mydomain, mail.$mydomain
local_recipient_maps = ldap:/etc/postfix/ldapvirtual.cf
local_transport = lmtp:unix:/var/lib/imap/socket/lmtp
...

/etc/postfix/ldapvirtual.cf is LDAP configuration file to search for mail addresses.

What do I need to configure on postfix?

Marko
  • 271
  • 5
  • 18

1 Answers1

2

In master.cf you create a new "ruby" configuration for the ruby script to accept mails. This is done via pipe as described in http://www.postfix.org/pipe.8.html You can probably already see some examples (with pipe in the last column) in your current master.cf. But how to configure it depends on the ruby script and the related system environment.

Then you need a file (for example) /etc/postfix/transport_maps with the content

someuser@example.com    ruby:
other@example.net    ruby:

This will pass mails for these persons to the ruby transport you configured in master.cf as long as you named it "ruby". Then run postmap /etc/postfix/transport_maps.

After that you need a new line in main.cf with

transport_maps = hash:/etc/postfix/transport_maps

Reload the Postfix daemon. From then the configured addresses go through ruby and the others go through the transport configured with local_transport.

mailq
  • 16,882
  • 2
  • 36
  • 66
  • I did as suggested, but mails to above example someuser@example.com is being rejected with error 550 Recipient address rejected: User unknown in local recipient table ##. I guess that I need to add above address to some other maps, but I don't know to which map and to what it should point to? – Marko Sep 07 '11 at 09:47
  • This is absolutely unrelated to this question. This has to be fixed before asking this question. The address must be in your LDAP (and the domain, too). – mailq Sep 07 '11 at 10:48
  • If I add address to LDAP, it will automatically deliver to user account (since cyrus will create non existant account on delivery attempt). How does postfix decides to deliver to particular transport? If seems to me that postfix is ignoring transport_maps in my setup (postconf does show it is configured). – Marko Sep 07 '11 at 11:12
  • Postfix decides on the transport map as described in http://www.postfix.org/transport.5.html – mailq Sep 07 '11 at 11:14
  • You were right. After I cleaned a lot of other configuration that were causing problems, **it worked**! – Marko Sep 07 '11 at 17:17