Score:1

How do I automatically BCC received mail to multiple users in Postfix?

cn flag

I am trying to link up a dummy email address to two different email addresses:
contact@example.com -> user1@example.com and user2@example.com
This would mean that mail sent to contact@example.com would also get BCC'd or forwarded to user1@example.com and user2@example.com

I am having trouble with the recipient_bbc_maps config:

# /etc/postfix/main.cf
recipient_bcc_maps = pcre:/etc/postfix/recipient_bcc_map
# /etc/postfix/recipient_bbc_map
## This works
/^contact@example\.com$/ user1@example.com

## This doesn't work
/^contact@example\.com$/ user1@example.com,user2@example.com

The suggestion was taken from https://serverfault.com/a/183491, but it doesn't work.
Postfix can receive and send messages, so I know that my config is good so far. What am I doing wrong?

# /var/log/mail.log
postfix/qmgr[594770]: 309D64800B2: from=<sender@gmail.com>, size=3250, nrcpt=2 (queue active)
postfix/local[594799]: 309D64800B2: to=<contact@example.com>, relay=local, delay=0.02, delays=0.01/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
postfix/local[594799]: 309D64800B2: to=<user1@example.com, user2>, orig_to=<user1@example.com,user2@example.com>, relay=none, delay=0.02, delays=0.01/0.01/0/0.01, dsn=5.1.3, status=bounced (bad address syntax)
postfix/qmgr[594770]: 309D64800B2: removed
Score:1
it flag

The error message is pretty clear:

orig_to=<user1@example.com,user2@example.com>
bad address syntax

You cannot specify multiple addresses in a bcc-maps.

https://stackoverflow.com/questions/22537523/postfix-recipient-bcc-maps-multiple-recipients-how-to explains how to workaround this feature:

  • create a virtual map to have the distribution list ;
  • send BCC to the vmap

The Bcc will be expanded to the whole distribution list

#/etc/postfix/recipient_bcc_maps
source@domain.tld    rcpt@domain.tld


#/etc/postfix/vmaps
rcpt@domain.tld    rcpt1@domain.tld,rcpt2.domain.tld,rcpt3@domain.tld
cn flag
Thank you, I forgot that virtual aliases can do this!
Gaétan RYCKEBOER avatar
it flag
De nada :) Maps are often evil.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.