mail-archiver

mail-archiver

Docker app from Emphyrio's Repository

Overview

Mail Archiver is a web-based solution for archiving, searching, and exporting emails. All emails and attachments are stored in a Postgresql database. Also supports OpenID Connect (OIDC) for Single Sign On. The documentation contains examples for Authelia and Microsoft Entra ID.

📧 Mail-Archiver - Email Archiving System

A comprehensive solution for archiving, searching, and exporting emails

🌐 Website: mail-archiver.org

Website Docker .NET PostgreSQL Bootstrap Buy Me a Coffee Ko-fi

✨ Key Features

📌 Core Features

  • Automated archiving from multiple accounts with scheduled sync
  • Multilingual responsive UI with dark mode
  • OpenID Connect (OIDC) authentication (OIDC Guide)

🔍 Search & Access

  • Advanced search with filters
  • Email preview with attachments
  • Export accounts or selected emails as mbox / zipped EML
  • Read-only REST API (v1) for programmatic access to the archive via scoped per-user API keys — lets scripts and AI agents read archived mail without ever exposing mailbox credentials (REST API Guide)

👥 User Management

  • Multi-user support with account-specific permissions
  • Dashboard with statistics and storage monitoring
  • Detailed access logging (Access Logging Guide)

🧩 Email Provider Support

  • IMAP: Traditional IMAP accounts with full synchronization capabilities
  • M365: Microsoft 365 mail accounts via Microsoft Graph API (Setup Guide)
  • Microsoft Personal: Personal Microsoft accounts (Outlook.com, Hotmail, live.com, M365 Family) via OAuth2 Device Code Flow — ships with a pre-registered shared Client ID so no Azure App Registration is required (Setup Guide)
  • IMPORT: Import-only accounts for migrating existing email archives

🏢 M365 Tenant Import

  • Bulk-import all Microsoft 365 mailboxes of a tenant from one form
  • Import all mailboxes or select specific ones; skips existing and disabled accounts
  • See the M365 Tenant Import Guide for details

📥 Import & Restore Functions

  • MBox and EML (ZIP) import with folder structure support
  • Restore emails or entire mailboxes
  • 📤 Mailbox Migrations: Copy emails between mailboxes while preserving folder structure (Migration Guide)

🗑️ Retention Policies

  • Automatic deletion from mailserver after a configurable period (Retention Policies)
  • Per-account retention (e.g., 30, 90, or 365 days)
  • Separate retention for the local archive

🔒 Deletion Lock (Compliance)

  • Disable manual deletion of archived emails via DeletionPolicy__DeletionAllowed=false
  • Local retention deletion remains exempt and still runs
  • See Setup Guide for details

📋 Access Log

  • The application logs various types of user activities such as Login, Opening, Searches, Exports and many more. (Logging)

📚 Documentation

For detailed documentation on installation, configuration, and usage, please refer to the Documentation Index. Please note that the documentation is still fresh and is continuously being expanded.

🖼️ Screenshots

Dashboard

Mail-Archiver Dashboard

Archive

Mail-Archiver Archive

Email Details

Mail-Archiver Mail

🚀 Quick Start

Prerequisites

🛠️ Installation

  1. Install the prerequisites on your system

  2. Create a docker-compose.yml file

services:
  mailarchive-app:
    image: s1t5/mailarchiver:latest
    restart: always
    environment:
      # Database Connection
      - ConnectionStrings__DefaultConnection=Host=postgres;Database=MailArchiver;Username=mailuser;Password=masterkey;

      # Authentication Settings
      - Authentication__Username=admin
      - Authentication__Password=secure123!

      # TimeZone Settings
      - TimeZone__DisplayTimeZoneId=Etc/UCT
    ports:
      - "5000:5000"
    networks:
      - postgres
    volumes:
      - ./data-protection-keys:/app/DataProtection-Keys
    depends_on:
      postgres:
        condition: service_healthy


  postgres:
    image: postgres:17-alpine
    restart: always
    environment:
      POSTGRES_DB: MailArchiver
      POSTGRES_USER: mailuser
      POSTGRES_PASSWORD: masterkey
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    networks:
      - postgres
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mailuser -d MailArchiver"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

networks:
  postgres:
  1. Edit the database configuration in the docker-compose.yml and set a secure password in the POSTGRES_PASSWORD variable and the ConnectionString.

  2. Definie a Authentication__Username and Authentication__Password which is used for the admin user.

  3. Adjust the TimeZone__DisplayTimeZoneId environment variable to match your preferred timezone (default is "Etc/UCT"). You can use any IANA timezone identifier (e.g., "Europe/Berlin", "Asia/Tokyo").

  4. Configure a reverse proxy of your choice with https to secure access to the application.

⚠️ Attention The application itself does not provide encrypted access via https! It must be set up via a reverse proxy!

  1. Initial start of the containers:
docker compose up -d
  1. Restart containers:
docker compose restart
  1. Access the application in your prefered browser.

  2. Login with your defined credentials and add your first email account:

  • Navigate to "Email Accounts" section
  • Click "New Account"
  • Enter your server details and credentials
  • Save and start archiving!
  • If you want, create other users and assign accounts.

🔐 Security Notes

  • Use strong passwords and change default credentials
  • Consider implementing HTTPS with a reverse proxy in production
  • Regular backups of the PostgreSQL database recommended (see Backup & Restore Guide for detailed instructions)

⚙️ Advanced Setup

For a complete list of all configuration options, please refer to the Setup Guide.

📋 Technical Details

Architecture

  • ASP.NET Core 10 MVC application
  • PostgreSQL database for email storage
  • MailKit library for IMAP communication
  • Microsoft Graph API for M365 email access
  • Background service for email synchronization
  • Bootstrap 5 and Chart.js for frontend

🤝 Contributing

We welcome contributions from the community! Please read our Contributing Guide for detailed information about how to contribute to Mail Archiver.

For code changes by third parties, please coordinate with us via email at mail@s1t5.dev before making any changes.

You can also:

  • Open an Issue for bug reports or feature requests
  • Submit a Pull Request for improvements
  • Help improve documentation

💖 Support the Project

If you find this project useful and would like to support its continued development, you can buy me a coffee! Your support helps me dedicate more time and resources to improving the application and adding new features. While financial support is not required, it is greatly appreciated and helps ensure the project's ongoing maintenance and enhancement.

Buy Me a Coffee Ko-fi GitHub Sponsors

🌟 Project Sponsors

With the generous support of our sponsors, Mail Archiver continues to evolve. Thank you for making it possible!

Disclaimer: The services listed above are third-party offerings and are neither affiliated with, endorsed by, nor tested by the Mail Archiver project.

Admin Intelligence

💝 Individual Sponsors

A special thanks to all individual sponsors who support this project through GitHub Sponsors, Ko-fi, and Buy Me a Coffee. Your contributions make a real difference!


📄 License: GNU GENERAL PUBLIC LICENSE Version 3 (see LICENSE file)

Install mail-archiver on Unraid in a few clicks.

Find mail-archiver in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.

Open the Apps tab on your Unraid server Search Community Apps for mail-archiver Review the template variables and paths Click Install

Requirements

PostgreSQL database container (e.g. postgresql17).

Categories

Download Statistics

769,735
Total Downloads
124,222
This Month
105,967
Avg / Month

Total Downloads Over Time

Loading chart...

Related apps

Explore more like this

Explore all

Details

Repository
s1t5/mailarchiver
Last Updated2026-06-29
First Seen2025-10-16

Runtime arguments

Web UI
http://[IP]:[PORT:5000]
Network
bridge
Shell
sh
Privileged
false

Template configuration

Web UI PortPorttcp

Web interface port

Target
5000
Default
5000
Value
5000
Folder for Data Protection KeysPathrw

Folder for storing data protection keys

Target
/app/DataProtection-Keys
Default
/mnt/user/appdata/mailarchiver/data-protection-keys
Value
/mnt/user/appdata/mailarchiver/data-protection-keys
Database Connection StringVariable

PostgreSQL connection string. Format: Host=postgres-ip-address;Port=5432;Database=dbname;Username=user;Password=pass; Replace 'postgres' with your PostgreSQL IP address (on bridge network) or container name (on custom network) and update credentials as needed.

Target
ConnectionStrings__DefaultConnection
Default
Host=postgres-ip-address;Port=5432;Database=MailArchiver;Username=mailuser;Password=masterkey;
Value
Host=postgres;Port=5432;Database=MailArchiver;Username=mailuser;Password=masterkey;
Admin UsernameVariable

The username for the admin account.

Target
Authentication__Username
Default
admin
Value
admin
Admin PasswordVariable

The password for the admin account.

Target
Authentication__Password
Default
secure123!
Value
secure123!
Display Time ZoneVariable

The time zone used for displaying email timestamps in the UI. Use any TZ identifier from: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Target
TimeZone__DisplayTimeZoneId
Default
Etc/UTC
Value
Etc/UTC
OAuth EnabledVariable

Set to true to enable OIDC authentication.

Target
OAuth__Enabled
Default
false
Value
false
OAuth AuthorityVariable

The OIDC authority/issuer URL of your identity provider (e.g. for Authelia: https://auth.example.com/). Note the trailing slash at the end.

Target
OAuth__Authority
Default
https://auth.example.com/
Value
https://auth.example.com/
OAuth Client IdVariable

OIDC client ID configured in your identity provider (e.g. Authelia) for Mail Archiver.

Target
OAuth__ClientId
Default
mail-archiver
Value
mail-archiver
OAuth Client SecretVariable

Client secret for the OIDC client.

Target
OAuth__ClientSecret
OAuth Disable Password LoginVariable

Set to true to disable traditional username/password login and enforce OAuth-only authentication.

Target
OAuth__DisablePasswordLogin
Default
false
Value
false
OAuth Auto Approve UsersVariable

If set to true, new OIDC users are automatically approved. Enable if you manage your users exclusively in your OIDC provider.

Target
OAuth__AutoApproveUsers
Default
false
Value
false
OAuth Client Scopes 0Variable

Scope #1 as requested from the identity provider.

Target
OAuth__ClientScopes__0
Default
openid
Value
openid
OAuth Client Scopes 1Variable

Scope #2 as requested from the identity provider.

Target
OAuth__ClientScopes__1
Default
profile
Value
profile
OAuth Client Scopes 2Variable

Scope #3 as requested from the identity provider.

Target
OAuth__ClientScopes__2
Default
email
Value
email
Session Timeout (Minutes)Variable

The session timeout in minutes.

Target
Authentication__SessionTimeoutMinutes
Default
60
Value
60
Cookie NameVariable

The name of the authentication cookie.

Target
Authentication__CookieName
Default
MailArchiverAuth
Value
MailArchiverAuth
Mail Sync Interval (Minutes)Variable

The interval in minutes between email synchronization.

Target
MailSync__IntervalMinutes
Default
15
Value
15
Mail Sync Timeout (Minutes)Variable

The timeout for the sync operation in minutes.

Target
MailSync__TimeoutMinutes
Default
60
Value
60
Connection Timeout (Seconds)Variable

The connection timeout for IMAP connections in seconds.

Target
MailSync__ConnectionTimeoutSeconds
Default
180
Value
180
Command Timeout (Seconds)Variable

The command timeout for IMAP commands in seconds.

Target
MailSync__CommandTimeoutSeconds
Default
300
Value
300
Always Force Full SyncVariable

Whether to always force a full sync (true/false).

Target
MailSync__AlwaysForceFullSync
Default
false
Value
false
Ignore Self-Signed CertificatesVariable

Whether to ignore self-signed certificates (true/false).

Target
MailSync__IgnoreSelfSignedCert
Default
false
Value
false
Batch Restore Async ThresholdVariable

The number of emails that triggers async processing.

Target
BatchRestore__AsyncThreshold
Default
50
Value
50
Max Sync EmailsVariable

The maximum number of emails for sync processing.

Target
BatchRestore__MaxSyncEmails
Default
150
Value
150
Max Async EmailsVariable

The maximum number of emails for async processing.

Target
BatchRestore__MaxAsyncEmails
Default
50000
Value
50000
Batch Restore Session Timeout (Minutes)Variable

The session timeout for batch restore in minutes.

Target
BatchRestore__SessionTimeoutMinutes
Default
30
Value
30
Default Batch SizeVariable

The default batch size for email operations.

Target
BatchRestore__DefaultBatchSize
Default
50
Value
50
Batch Operation SizeVariable

The batch size for email operations.

Target
BatchOperation__BatchSize
Default
50
Value
50
Pause Between Emails (ms)Variable

The pause between individual emails in milliseconds.

Target
BatchOperation__PauseBetweenEmailsMs
Default
50
Value
50
Pause Between Batches (ms)Variable

The pause between batches in milliseconds.

Target
BatchOperation__PauseBetweenBatchesMs
Default
250
Value
250
Max Selectable EmailsVariable

The maximum number of emails that can be selected at once.

Target
Selection__MaxSelectableEmails
Default
250
Value
250
Database Command TimeoutVariable

The timeout for database commands in seconds.

Target
Npgsql__CommandTimeout
Default
900
Value
900
Max Upload File Size (GB)Variable

The maximum file size for uploads in GB.

Target
Upload__MaxFileSizeGB
Default
10
Value
10
Upload Keep Alive Timeout (Hours)Variable

The keep alive timeout for uploads in hours.

Target
Upload__KeepAliveTimeoutHours
Default
4
Value
4
Upload Request Headers Timeout (Hours)Variable

The timeout for request headers in hours.

Target
Upload__RequestHeadersTimeoutHours
Default
2
Value
2