Configuring the mail server for email archiving with piler enterprise edition#

Revision #1

Publication date: Apr 20, 2023

Configure the mail server#

To start archiving emails you have to configure your mail servers to copy each and every single email they receive to piler via SMTP.

The configuration process depends on the used mail server. We’ll use archive@archive.yourdomain.com address as an example where to send the emails. Be sure to use your own archive’s domain name!

For multi-tenant installations the local part must match the customer (=tenant) ID, eg. if the customer id is “customer1”, then the address to forward emails is customer1@archive.yourdomain.com.

Postfix#

Add the following to main.cf then issue the postfix reload command:

always_bcc = archive@archive.yourdomain.com

Axigen#

Open the Axigen web admin interface. Go to “SECURITY & FILTERING”, then click on “Acceptance & Routing”, finally click on “ADVANCED SETTINGS”.

Click on “ADD ACCEPTANCE / ROUTING RULE”, and fill the rule name, the conditions and the actions fields, see the example below. Then click on the “SAVE CONFIGURATION” button.

Office 365#

Configure networking, and make sure that Office 365 can reach archive.yourdomain.com on port 25. This may require setting some firewall rules, etc.

Create a mailbox for NDR reports#

Login at office 365 admin portal, then go to “Users” → “Active users” menu, and create a user for receiving undeliverable journal reports, eg. ndr-reports@yourdomain.com.

Create a journaling rule#

Go to Exchange admin center, then “compliance management”, and select “journal rules”. Click right next to “Send undeliverable journal reports to:”, and specify the address you just created (ie. ndr-reports@yourdomain.com).

Microsoft Exchange in general#

Basically you have to create SMTP journaling in Exchange, find the details on the different Exchange versions below.

Note that you may have to force the GUI to rewrite the Message-id header field preventing Exchange to discard the restored message as a duplicate. Edit config-site.php, and set the following:

$config['REWRITE_MESSAGE_ID'] = 1;

Exchange 2003#

Exchange 2007#

Create SMTP contact#

Configure Message Format Settings#

With this setting, journal reports are sent in MIME rather than S/TNEF.

Enable Standard Journaling#

Exchange 2010#

Create SMTP Contact#

Enable Standard Journaling#

Create a Send Connector#

Exchange 2013#

Setup Journaling#

Create a Send Connector#

Adjust Maximum Message Size#

By default, the maximum send message size for the Connector is set to 10 MB. To change this:

Disable Non Delivery Reports (optional)#

Kerio Connect#

See the detailed instructions at https://manuals.gfi.com/en/kerio/connect/content/server-configuration/archiving-and-backup/archiving-in-kerio-connect-1164.html for notenant piler installations (“Archiving the whole server”) as well as multi-tenant piler installations (“Archiving individual domains”).

Zimbra#

Zimbra uses postfix internally, so you may use the postfix approach: find the zimbra version of main.cf, and apply the same as for postfix.

Exim#

For no-tenant deployments, create a system wide filter, eg. /etc/exim.filter with the following content:

unseen deliver archive@archive.yourdomain.com

Then specify the filter in your exim config file (on Ubuntu create /etc/exim4/conf.d/main/30_exim4-config_system_filter), and restart exim:

system_filter = /etc/exim.filter

Also check out http://www.exim.org/exim-html-current/doc/html/spec_html/ch-some_common_configuration_settings.html

Notes for mail service providers#

This chapter applies to mail service providers, how to configure postfix to send copies of emails to the archive properly.

The problem#

if you set always_bcc = some@address, then postfix sends a copy of messages to some@address. Let’s say you host mailboxes for both customer1.com and customer2.com. Now if customer1 sends an email to customer2, then postfix will send a single copy only to customer2@, so the email is archived for customer2 only, but customer1 won’t see this email in their archive.

The solution#

Configure postfix in the following way. The below config also enables you to selectively archive emails for specific domains or mailboxes only.

/etc/postfix/main.cf:

recipient_bcc_maps = pcre:/etc/postfix/bcc_map
sender_bcc_maps = pcre:/etc/postfix/bcc_map
smtp_destination_recipient_limit = 1

/etc/posfix/bcc_map:

/(.+)@customer1\.com/ customer1@archive.yourdomain.com
/(.+)@customer2\.com/ customer2@archive.yourdomain.com
/(.+)@customer3\.com/ customer3@archive.yourdomain.com

Alternate solution if postfix and piler smtp are on the same host:

Let postfix listen on the public interface, and piler-smtp on the localhost, and apply the following setup:

myhostname = smtp-gw.aaa.fu
virtual_mailbox_domains = archive.yourdomain.com
virtual_alias_maps = pcre:/etc/postfix/bcc_map
smtp_destination_recipient_limit = 1
content_filter = smtp:[127.0.0.1]:25