I try to explain better...
Actually I have a standalone mailserver (CentOS7+postfix+dovecot) that provide some mailboxes for my domains and I want to add a Backup MX.
As said in lot of doc (http://www.akadia.com/services/postfix_mx_backup.html) a backup MX usually keep mails in his queue and keep try to forward them to the main MX server until it came back online.
But, as I know, is not possible to easy access to these mails in order to read them when the main MX server is down (yes, I can go to /var/spool/mail/somewhere by SSH in case of emergency but this is far away of "mailbox" concept).
So my idea is to deliver a copy of all mails that arrive on the backup MX to a local mailbox too where I can read them with a dedicated webmail. The other copy still be in mail queue ready to be delivered to the main MX when possible (as standard backup MX configuration).
So the question is, how do it? master.cf support customs route for mails (I use a pipe here to forward mails to spamassassin without use amavis, for example) but I wasn't able to locate an how-to/manual/example to do something like that.
UPDATE:
I found a workaround that works fine for me, I'll add it here and leave the question open for answers or suggestions because I'm not sure that is the best possible solution...
I actually configured the backup MX with the same postfix/dovecot config of main MX (with local mailboxes, users etc) and add it as MX to DNS (lower priority that main MX).
Then I configured a rule that add a BCC to all incoming mails following this guide: http://www.linuxmail.info/backup-mail-postfix/
In main.cf I added:
recipient_bcc_maps = pcre:/etc/postfix/backup_bcc.pcre
transport_maps = hash:/etc/postfix/transport
smtp_generic_maps = pcre:/etc/postfix/generic.pcre
The backup_bcc.pcre contain a rule that add a bcc adding .backupmx to the recipient domain (making it an invalid local domain):
/^(.*)@example\.com$/ [email protected]
The transport map contain a rule to forward all mails for .backupmx to the main MX:
.backupmx smtp:[1.2.3.4]
And must be compiled in db format with:
postmap /etc/postfix/transport
And the generic.pcre contain a rule to remove .backupmx ext before forward it to the main MX:
/^(.*)@example\.com\.backupmx$/ [email protected]
So, if a mail is sent to my backup MX (due main MX down) the mail is delivered to the local mailbox and forwarded to the main MX (or, if unreachable, keep in queue until came back online).
I also added
-o receive_override_options=no_address_mappings
to my master.cf as suggested by Rob here https://serverfault.com/a/28484/348531 in order to avoid duplicate-BCC problem cause by content filter.
0 Answers