A utility to export email folders from an IMAP server to local mbox files with YAML configuration and optional gzip compression.
Free for personal and non-commercial use. Contact me if youβd like to use it in your business.
Features:
Add my repo https://deb.blindage.org/#ubuntudebian
and install imap2mbox.
With this image you can use it inside docker or kubernetes cronjob:
ghcr.io/21h/imap2mbox:1.0
Requres volume. Download helm chart package imap2mbox-cronjob with CronJob.
Create pvc.yaml for your backup volume and save:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: imap2mbox
spec:
accessModes:
- ReadWriteOnce
storageClassName: csi-s3-cold
resources:
requests:
storage: 1GiNow create all resources:
namespace="mail"
# create secret with config file
kubectl create secret generic imap2mbox-credentials --namespace ${namespace} \
--from-file=./config.yaml --dry-run -o yaml > mbox-secret.yaml
kubectl apply -n ${namespace} -f mbox-secret.yaml
# create pvc with your backup storage
kubectl apply -n ${namespace} -f pvc.yaml
helm upgrade imap2mbox-backup -n ${namespace} --install imap2mbox-cronjob-1.0.0.tgzCreate a config.yaml file in the same directory as the
script:
imap:
host: "imap.example.com"
port: 993
username: "user@example.com"
password: "secret"
tls: true # implicit TLS, port 993
starttls: false # STARTTLS upgrade, port 143 (mutually exclusive with tls)
folders:
- INBOX
- Sent
- Drafts
- Archive
- Spam
output:
dir: "./backup" # one .mbox file per folder will be created here
gzip: false # set true to write .mbox.gz instead
max_message_size: 0 # bytes, 0 = no limit (e.g. 10485760 = 10 MB)By default program search config.yaml in current
directory or use:
imap2mbox -config config_for_mail.ru.yaml
imap2mbox -config config_for_gmail.com.yaml| Option | Description |
|---|---|
-config PATH |
Path to YAML configuration file (default: config.yaml) |
-dry-run |
Scan and report without writing anything |
Unpack mbox file before import into Claws Mail.
config.yaml with proper permissions
(chmod 600 config.yaml)Copyright by Vladimir Smagin, 2026.
Contacts: