Skip to main content

Clean Mail Automation configuration

Environment variables​

VariableDefaultDescription
IMAP_SERVERnoneIMAP hostname. Required unless MAILBOX_CONFIGS is set.
IMAP_PORT993IMAP port. The connection always uses SSL/TLS.
EMAIL_USERnoneIMAP username. Required.
EMAIL_PASSnoneIMAP password. Required.
EMAIL_ADDRESSEMAIL_USERLabel in logs, status page and notifications.
MAILBOXINBOXFolder to clean.
CLEAN_DAYS10Delete emails older than this many days. --days overrides it.
MAILBOX_CONFIGSnoneJSON array for multi-mailbox mode. Replaces the single-mailbox variables above: each entry needs its own server and credentials. Only CLEAN_DAYS still applies, as the default for entries without clean_days.
SEND_TELEGRAM_NOTIFICATIONSfalseEnable Telegram (1, true, yes, on).
TELEGRAM_BOT_TOKENnoneBot token. Required when Telegram is enabled.
CLEAN_EMAIL_TELEGRAM_CHAT_IDnoneChat ID for this app. Takes priority over TELEGRAM_CHAT_ID.
TELEGRAM_CHAT_IDnoneFallback chat ID, handy when several apps share one variable.
TELEGRAM_TIMEOUT10Telegram API timeout, in seconds.
TELEGRAM_NOTIFY_MODEalwaysalways: a message after every run. digest: collect results and send them on the DIGEST_SCHEDULE_* cron.
TELEGRAM_NOTIFY_ONLY_IF_DELETEDfalseSkip runs where nothing was deleted (both modes).
SCHEDULE_MIN0Cleanup cron minute.
SCHEDULE_HOUR0Cleanup cron hour.
SCHEDULE_DAY0Cleanup cron weekday: 0/7 Sunday … 6 Saturday, * every day.
DIGEST_SCHEDULE_MIN0Digest cron minute (digest mode only).
DIGEST_SCHEDULE_HOUR8Digest cron hour (digest mode only).
DIGEST_SCHEDULE_DAY0Digest cron weekday (digest mode only).
WEB_PORT8080Port of the status page inside the container. To use another host port, change the ports mapping instead (e.g. "3200:8080").
TZUTCContainer timezone: cron schedule and timestamps. The status page clock uses your browser's time.

With the defaults the cleanup runs every Sunday at 00:00. Cron fields accept digits, *, /, , and -; anything else falls back to the default and is logged.

CLI arguments​

ArgumentDescription
--days NRetention for this run only; overrides CLEAN_DAYS and every clean_days.
--send-digestSend the collected Telegram digest, clear it and exit. The digest cron calls this.
--forceWith --send-digest: send even when nothing was collected (a "nothing to report" message).

Inside the container: docker exec email_cleaner python3 /app/clean_email.py --days 30.