Recently, I had need of setting up a postfix “smtp router” to distribute mail from various users among a cluster of outbound relays (on unique exit IP’s, with difference QoS policies applied)

Part of the functionality that was desired was the ability to route “priority” users and “bulk” users via different cluster members.

Step 1 – Upgrade postfix to > 3.1.x

Not going to tell you what to do here. google! is your friend.

Step 2 – Edit /etc/postfix/main.cf, add the following line to the bottom of the configurations.

$ vim /etc/postfix/main.cf
sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport_maps

Step 3 – Create the transport maps

Using your favorite editor (Vim/Nano/Vi) edit the postfix transport maps.

$ vim /etc/postfix/sender_transport_maps
# Priority Senders
# priority.smtprelay is configured in /etc/hosts to resolve to SMTP relay reserved for Priority users (duh) with higher bandwidth.
priorityuser1@domain.com smtp:[priority.smtprelay]
priorityuser2@domain.com smtp:[priority.smtprelay]

# Bulk Senders
# bulk.smtprelay resolves to a relay with less bandwidth allocatedmarketing@domain.com smtp:[bulk.smtprelay]
info@domain.com smtp:[bulk.smtprelay]

# All other mail delivers via the relay configured in relayhost= on main.cf OR via direct MX

Step 4 – Hash the configurations done above

$ postmap /etc/postfix/sender_transport_maps

Step 5 – Restart postfix

$ /etc/init.d/postfix restart

Step 6 – Analyze Logs

Tail the logs, and watch your mail get distributed between your relays.

$ tail -f /var/log/maillog
Print Friendly, PDF & Email