Get Concurrent Relay Recipients

This perl script will pull all users’ SMTP addresses from your Active Directory (including primary and secondary email addresses) and list them in the format “user@example.com OK” which Postfix uses with relay_recipient_maps. It will also automatically create a mynetworks file, transport file, and relay_domains file to ensure all information is properly included.

UPDATE: This files have moved to my Codaset account. They are available here.

To run this scrpit, simply put it in cron and run it. Ensure that postfix is reloaded so all changes made to the postfix configuration files take effect. The cron entry should look as follows:

# /usr/local/bin/getcrr.pl && postfix reload && /etc/init.d/amavis restart

Some features of this program are that all LDAP queries run in parallel using a forking model. This means that you can set up as many servers as you want and it will run the queries in a parallel fashion to complete the requests in as timely a manner as possible. The script creates a relay_recipients file, a transport file, a relay_domains file, and a my networks file.

Their associated entries in /etc/postfix/main.cf should look as follows:

mynetworks = pcre:/etc/postfix/mynetworks
relay_domains = pcre:/etc/postfix/relay_domains
relay_recipient_maps = pcre:/etc/postfix/relay_recipients
smtpd_recipient_restrictions = ... check_recipient_access pcre:/etc/postfix/relay_recipients ...
transport_maps = pcre:/etc/postfix/transport

If you have any questions/comments/concerns/feedback (all of which are appreciated), get in contact with me.

Links: This program is listed on the Postfix Wiki.