Mailbox and Mail Repository Store for Mail Persistence

Introduction

The Mailbox persists users' Inbox, Sent Items, Trash... folders with their mails.

The Mail Repository Store persists spam, error,... mails, so nothing to do with users visible mails.

In case of database access, both Mailbox and Mail Repository Store use database connection defined via database.properties.

Mailbox Persistence

Apache James Server uses the Apache James Mailbox storage system to store the users mailboxes.

The mailbox library supports different persistence mecanisms: MailDir, Database (via JPA) and JCR.

Mailbox persistence is configured in spring-beans.xml (by default JPA, you set the database connection properties in database.properties - can also be MailDir, JCR).

Mail Repository Store Persistence

Mail repository allow the administrator to store mail being processed in the mailet-container. The mails are typically added by the ToRepository mailet. Then for Guice wiring webAdmin API allows to read, delete and reprocess these mails.

Typical use cases might be:

  • Error management: mails can be stored if an error is encountered during the mail processing, be the error caused by a bug, a configuration mistake, a parsing error, temporary unavailable services. Reprocessing the mails once the problem fixed allows to avoid data loss. Note that you can use mail repositories of different types on the same James server in order to not be dependant from a single data-store.
  • Debugging: MDC context allows to follow mail processing, and isolate logs of a single mail. You can then configure James in order to collect all mails processed in one part of your pipeline, and thus better understand this one.
  • Data collection: Collect spam, suspicious mails and much more. You can then later on analyze them or for instance train your anti-spam system.

Available Mail Repository Store are defined in mailrepositorystore.xml. Each has an URL prefix (file, db, dbfile,...) that can be used in mailetcontainer.xml to define where to store spam,... mails (example: file://var/mail/error/).

More information about the mailstores configuration can be found here.

Mail Repository Stores are distinguished by how they store data. There are five types of storage: File, Database, DBFile.

Domain Persistence

Read more on how to configure domain persistence.

User Persistence

Read more on how to configure users persistence.