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.


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$/ $1@example.com.backupmx

The transport map contain a rule to forward all mails for .backupmx to the main MX:

.backupmx smtp:[]

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$/ $1@example.com

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.

migrated from superuser.com May 1 '16 at 10:48

This question came from our site for computer enthusiasts and power users.

  • What have you tried? What did you expect to happen? What happened instead? What does your config look like? Do you have any log entries from the times it didn't work as expected? – Jenny D May 1 '16 at 11:35
  • Not really tried yet, I'm still trying to focus how approach the problem... Summarizing I'm asking how split an an incoming mail on two route, one for local delivery and other one for backup MX. – Tsumi May 1 '16 at 12:13
  • I also tried to configure the backup postfix for local delivery (same config of main mailserver) and then apply the config for backup MX. Mails are successfully forwarded to main mailserver but not delivered locally and on logs i get: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains. So I think that this is not the proper way to do what I mean. – Tsumi May 1 '16 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.