Postfix transport maps

I have 2 servers (A,B) with email server working. I am trying to replicate all emails sent to server A to server B using transport map. My transport table is

CREATE TABLE `transport` (
    `domain` varchar(128) NOT NULL DEFAULT '',
    `transport` varchar(128) NOT NULL DEFAULT '',
    UNIQUE KEY `domain` (`domain`) 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

When I add row to that table to transport emails to server B it works

+-------------+----------------+
| domain      | transport      |
+-------------+----------------+
| example.com | smtp:[1.2.3.4] |
+-------------+----------------+

but when I try to add another server it stops working

+-------------+--------------------------------+
| domain      | transport                      |
+-------------+--------------------------------+
| example.com | smtp:[1.2.3.4], smtp:[2.3.4.5] |
+-------------+--------------------------------+

My question is, how to get it working? How can I get mails on two different servers replicated?


Solution 1:

Transport maps don't support multiple nexthops. You can try using auto_bcc (or one of the BCC maps) to deliver mail to additional addresses.

For example, to deliver all mail destined for example.com to server B, create a domain for the "backup" mail (e.g. backup.example.com) and configure server B to accept mail for this domain. Then use a regular expression recipient_bcc_maps table which adds the counterpart user on backup.example.com as a BCC.

main.cf:

recipient_bcc_maps = regexp:/etc/postfix/recipient_bcc_maps

recipient_bcc_maps:

/^(.*)@example\.com$/   ${1}@backup.example.com