Archiving Emails from Linux-based Email Servers

Synchronizing Users

Linux-based email servers support various database types for managing users. Additionally to the legacy user database know as the passwd file, LDAP-based databases such as OpenLDAP or Active Directory as well as SQL-based databases are often used. Instruction on setting up user synchronization with MailStore Server can be found in the following chapters of the MailStore Server manual:

Note: When batch-archiving IMAP mailboxes MailStore Server automatically creates non-existing users. The authentication type of those users will be set to MailStore-integrated.

Archiving Individual Mailboxes

Template:Archiving Archive Single Mailbox Preamble

Template:Archiving Archive Single Mailbox

Archiving Multiple Mailboxes in One Step

MailStore provides several methods for archiving multiple mailboxes in one step, which can be used with common IMAP servers on Linux-based email servers.

While the method Multiple IMAP Mailboxes (CSV File) does not require any special configuration on the IMAP server, it is normally necessary to modify the IMAP server's configuration before the 'Multiple IMAP Mailboxes (Master Password) method can be used.

Configuration of the IMAP Server

In the following you find instructions for the most common IMAP server on Linux servers, explaining how to enable access to the mailboxes using the PLAIN SASL method as described in RFC 4616.

Important notice:The following sections describe configuration changes that should only be performed by experienced administrators. The instructions do not cover configuration characteristics of the MTAs on different Linux distributions.

Dovecot IMAP

TODO

Cyrus IMAP

TODO

Configuration of MailStore Server

To learn more about archiving multiple mailboxes in one step, please refer to the chapter Batch-archiving_IMAP_Mailboxes of the MailStore Server manual.

Archiving Incoming and Outgoing Emails Directly

Archiving of all incoming and outgoing email directly requires that the used mail transfer agent (MTA) delivers copies of all email into a dedicated mailbox (called multidrop mailbox in the following). From this multidrop mailbox, emails can be archived by using a profile of type [Archiving_IMAP_and_POP3_Multidrop_Mailboxes|Multidrop Mailbox]] in MailStore Server.

Please notice: Emails can and should be automatically deleted after they have successfully been archived from a multidrop mailbox. You can configure this in the corresponding archiving profile.

Configuration of the Mail Transfer Agent

In the following it is explained how to set up the required copy function in the most popular mail transfer agent on Linux servers.

Important notice:The following sections describe configuration changes that should only be performed by experienced administrators. The instructions do not cover configuration characteristics of the MTAs on different Linux distributions.

Exim

First create a new mailbox that should act as a multidrop mailbox.

To deliver copies of all emails into a multidrop mailbox, it is necessary to add a new router as well as a new transport to the Exim configuration.

The configuration of the new Exim router should look like this:

mailstore_router:
  no_expn
  no_verify
  transport = mailstore_transport
  driver = accept
  unseen

Please make sure that the mailstore_router is passed through before the router responsible for delivering the messages to the actual user mailboxes. It is strongly recommended to enter it first in the Exim router configuration. Depending on your anti-spam or anti-virus protection it may also be suitable to put it right after the routers handling those actions.

The delivery into a multidrop mailbox is performed by the corresponding Exim transport, which is to be defined in the transport section of the Exim configuration. In this example, a transport called mailstore_transport is to be created. A new transport can be put anywhere in the Exim transport configuration. The following example shows the configuration of an Exim transport storing all emails in Maildir format in the directory /var/mailstore/Maildir. To store messages in a different location, please refer to the Exim manual.

mailstore_transport:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  return_path_add
  maildir_format = true
  create_directory = true
  directory = /var/mailstore/Maildir

After making these configuration changes, the Exim daemon must be restarted.

Postfix

First create a new mailbox that should act as a multidrop mailbox.

To have Postfix send a copy of all emails to this mailbox, you need to add the following line to the file main.cf:

 always_bcc = [email protected]

After making these configuration changes, the Postfix daemon must be restarted.

Sendmail

Because Sendmail is one of the most flexible mail transfer agent available, there is no best practice guide for setting up the functionality described above. How Sendmail is configured to send a copy of all emails to an additional mailbox mainly depends on your system environment. Since Sendmail 8.10 it is recommended to use the libmilter interface to add features to Sendmail.

A database with all available Milter plug-ins is available at https://www.milter.org. There is also a special section with archiving solutions. The listed plug-ins differ substantially in the way they are integrated into Sendmail and the way they work.

Qmail

First create a new mailbox that should act as a multidrop mailbox.

To have Postfix send a copy of all emails to this mailbox certain changes to be made before compiling the Qmail source code. The following guide is an adapted version of the article "Life with Qmail FAQ":

QUEUE_EXTRA is a compile-time configuration variable that specifies an additional recipient that will be added to every delivery. This is used primarily for logging; the FAQ describes how to use QUEUE_EXTRA to keep copies of all incoming and outgoing messages.

To use QUEUE_EXTRA, edit extra.h specifying the additional recipient in the format Trecipient\0, and the length of the QUEUE_EXTRA string in QUEUE_EXTRALEN (the "\0" counts as one character). For example:

 #define QUEUE_EXTRA "Tmailstore\0"
 #define QUEUE_EXTRALEN 11

Recompile the Qmail source code and restart the Qmail daemon to apply the changed.

Detailed information regarding Qmail can be found on the [Qmail Hompage] and [Life with qmail].

Configuration of MailStore Server

Template:Archiving Archive Multidrop Mailbox