Optional deletion of emails from IMAP source after successful archival #48

Open
opened 2026-04-05 16:16:16 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @DanMitrea on 2/6/2026

Problem Statement
When using Open Archiver with a dedicated archive mailbox (e.g., an Exchange mailbox that receives all emails via Transport Rules/BCC), the source mailbox continuously grows since archived emails remain on the IMAP server. This can lead to:

Mailbox quota issues
Increased storage costs
Performance degradation of the mail server
Unnecessary data duplication

Use Case
Many organizations use a dedicated "archive collection mailbox" pattern:

Exchange Transport Rule forwards/BCCs all emails to a dedicated mailbox (e.g., [email protected])
Open Archiver connects via IMAP to retrieve and archive these emails
Once archived, the emails in the source mailbox serve no further purpose and should be removed

This pattern is especially relevant for:

Exchange Server on-premises deployments
Microsoft 365 environments where auto-expanding archives are not available or desired
Organizations wanting to minimize Exchange storage footprint

Proposed Solution
Add an optional configuration setting for IMAP ingestion sources:
Option 1: Environment Variable
envIMAP_DELETE_AFTER_SYNC=true
IMAP_DELETE_RETENTION_DAYS=7 # Optional: keep emails for X days before deletion
Option 2: Per-Source Configuration
Add a toggle in the IMAP source configuration UI:

☐ Delete emails from source after successful archival
Optional: Retention period (days) before deletion

Implementation Details
The feature should:

Only delete emails that have been successfully archived (with confirmed hash storage)
Use IMAP STORE command to mark messages as \Deleted
Execute EXPUNGE to permanently remove flagged messages
Provide audit logging of deletion operations
Include error handling to prevent data loss if archival fails
Optionally: Respect a retention period (e.g., keep emails for 7 days after archival before deletion)

Safety Considerations

Default: OFF - This should be an opt-in feature to prevent accidental data loss
Only apply to IMAP sources (not Google Workspace/M365 Graph API)
Require explicit user confirmation when enabling this option
Log all deletions in the audit trail
Consider a "dry-run" mode to preview what would be deleted

Alternative Workarounds
Currently, users must implement external solutions:

Exchange Retention Policies
Custom PowerShell scripts
Third-party IMAP cleanup tools

A native Open Archiver solution would be cleaner and more reliable.
Related
This is particularly relevant for compliance scenarios where organizations need to:

Maintain a tamper-proof archive (Open Archiver)
Minimize production mail server storage
Ensure complete email capture without journaling complexity

*Originally created by @DanMitrea on 2/6/2026* Problem Statement When using Open Archiver with a dedicated archive mailbox (e.g., an Exchange mailbox that receives all emails via Transport Rules/BCC), the source mailbox continuously grows since archived emails remain on the IMAP server. This can lead to: Mailbox quota issues Increased storage costs Performance degradation of the mail server Unnecessary data duplication Use Case Many organizations use a dedicated "archive collection mailbox" pattern: Exchange Transport Rule forwards/BCCs all emails to a dedicated mailbox (e.g., [email protected]) Open Archiver connects via IMAP to retrieve and archive these emails Once archived, the emails in the source mailbox serve no further purpose and should be removed This pattern is especially relevant for: Exchange Server on-premises deployments Microsoft 365 environments where auto-expanding archives are not available or desired Organizations wanting to minimize Exchange storage footprint Proposed Solution Add an optional configuration setting for IMAP ingestion sources: Option 1: Environment Variable envIMAP_DELETE_AFTER_SYNC=true IMAP_DELETE_RETENTION_DAYS=7 # Optional: keep emails for X days before deletion Option 2: Per-Source Configuration Add a toggle in the IMAP source configuration UI: ☐ Delete emails from source after successful archival Optional: Retention period (days) before deletion Implementation Details The feature should: Only delete emails that have been successfully archived (with confirmed hash storage) Use IMAP STORE command to mark messages as \Deleted Execute EXPUNGE to permanently remove flagged messages Provide audit logging of deletion operations Include error handling to prevent data loss if archival fails Optionally: Respect a retention period (e.g., keep emails for 7 days after archival before deletion) Safety Considerations Default: OFF - This should be an opt-in feature to prevent accidental data loss Only apply to IMAP sources (not Google Workspace/M365 Graph API) Require explicit user confirmation when enabling this option Log all deletions in the audit trail Consider a "dry-run" mode to preview what would be deleted Alternative Workarounds Currently, users must implement external solutions: Exchange Retention Policies Custom PowerShell scripts Third-party IMAP cleanup tools A native Open Archiver solution would be cleaner and more reliable. Related This is particularly relevant for compliance scenarios where organizations need to: Maintain a tamper-proof archive (Open Archiver) Minimize production mail server storage Ensure complete email capture without journaling complexity
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OpenArchiver#48