How can I configure Postfix to retain copies of all email sent through it?
My company currently uses Google Apps for email. I can configure Google Apps to forward all outgoing email through a relay server. I can also point my MX records at this server and have it forward incoming mail onto Google. Therefore I can configure Postfix act as a proxy for all email that is both sent to and from our users. This part is done and works fine. However, I'm not sure how to retain a full copy of each message that passes through it.
I'm interested in doing this so that all email to/from customers can be dumped into our CRM system so they're searchable by everyone in our company who might talk to a customer. The most common way of doing this is to have a "always BCC" setting specified in Postfix. However, this would only archive email sent to customers, not email received from them. Does anyone have any suggestions? Thank you!
Solution 1:
You're mistaken - all mail is received, all mail is delivered.
As documented, always_bcc defines an address where copies of all mail handled by postfix are sent to.
Everything.
For better control over this process, use sender_bcc_maps and recipient_bcc_maps; some judicious use of regex maps allows you to copy the messages to the same user on an archive domain - for both senders and recipients, like so:
sender_bcc_maps = regexp:/etc/postfix/archive_domain
recipient_bcc_maps = regexp:/etc/postfix/archive_domain
In /etc/postfix/archive_domain
:
/^([^@]+)\@example\.com$/ [email protected]
You can now handle mail to @archive.example.com however you please.