Add NAS daily email report wrapper

Prompts used since the previous commit:
- Hoe regelen we het dagrapport?
- Het rapport moet per email naar mij gestuurd worden.
- hans@australius.nl
- akkoord

Special observations:
- dagelijks_overzicht.py now supports --mail-to and sends zero-message reports.
- QNAP plain deployment installs run_daily_report.sh with DAILY_REPORT_TO defaulting to hans@australius.nl.
- verplaats_log.json remains modified from the user's run and was intentionally not staged.
This commit is contained in:
2026-07-04 21:46:15 +02:00
parent 90d97efa6c
commit cfb96bc610
3 changed files with 55 additions and 16 deletions
+14 -3
View File
@@ -91,6 +91,14 @@ Scripts using shared IMAP folder handling:
- `dagelijks_overzicht.py`
- `sort_mail_daemon.py`
`dagelijks_overzicht.py` current behavior:
- Builds an HTML digest of messages that arrived on the selected date, defaulting to yesterday.
- Uses central `config.py`; select the mailbox account with `--account`, for example `--account backup`.
- Sends the digest via SMTP using the selected account credentials.
- Supports `--mail-to <address>`; the NAS daily report target is `hans@australius.nl`.
- Sends the report even when zero messages are found, so scheduled runs are visible.
Shared operation helpers:
- `mail_imap_ops.py` centralizes header decoding, FETCH payload extraction, routing fetched headers to full IMAP destinations, destination mailbox creation, and copy/delete move semantics for live sorting.
@@ -153,7 +161,8 @@ Remote/NAS deployment files:
- For the local NAS, use `SERVICE_MANAGER=plain`, `MAILCAT_HOME=/share/homes/mailcat`, and `PYTHON=/opt/bin/python3`. In plain mode, default paths are `APP_DIR=$MAILCAT_HOME/mailcat`, `STATE_DIR=$APP_DIR/state`, `LOG_DIR=$APP_DIR/log`, `RUN_DIR=$APP_DIR/run`, and `PID_FILE=$RUN_DIR/mailcat.pid`.
- QNAP path facts supplied by the user: `SUDO=/usr/bin/sudo`, `USERADD=/usr/local/bin/useradd`, `PYTHON=/opt/bin/python3`, `INSTALL=/usr/bin/install`, `SED=/bin/sed`, `TAR=/bin/tar`, `MKDIR=/bin/mkdir`, `CHOWN=/bin/chown`, `CHMOD=/bin/chmod`, and `RM=/bin/rm`. `nologin`, `python3`, `systemctl`, and `nohup` are not in the user's default PATH.
- The deploy script accepts absolute tool overrides for those commands and passes them into the remote script. In plain mode, the generated start/stop/status scripts also bake in absolute `MKDIR` and `RM` paths.
- In plain mode, the deploy script does not install systemd files. It writes executable scripts to `$APP_DIR/bin/start_mailcat.sh`, `$APP_DIR/bin/stop_mailcat.sh`, and `$APP_DIR/bin/status_mailcat.sh`.
- In plain mode, the deploy script does not install systemd files. It writes executable scripts to `$APP_DIR/bin/start_mailcat.sh`, `$APP_DIR/bin/stop_mailcat.sh`, `$APP_DIR/bin/status_mailcat.sh`, and `$APP_DIR/bin/run_daily_report.sh`.
- `DAILY_REPORT_TO` controls the report recipient during deploy and defaults to `hans@australius.nl`. The daily report wrapper appends output to `$LOG_DIR/daily_report.out`.
- `systemd/mailcat-sort.service` is a template consumed by `deploy_vps.sh`; after placeholder replacement it runs `sort_mail_daemon.py --account backup --folder INBOX` and stores state/logs under `/var/lib/mailcat` and `/var/log/mailcat`.
- `config.json` remains ignored and must be created manually on the remote host with mode `600` before starting the service.
@@ -255,8 +264,10 @@ Recommended next work:
- `sudo -u mailcat /share/homes/mailcat/mailcat/bin/start_mailcat.sh`
- `sudo -u mailcat /share/homes/mailcat/mailcat/bin/status_mailcat.sh`
- `tail -f /share/homes/mailcat/mailcat/log/sort_mail_daemon.log`
4. Send controlled test messages to `backup@australius.nl` for invoices, clear AI providers, a newsletter/service route, and unmatched mail; verify expected folder moves and daemon logs.
5. Add `List-ID` header support to mailing-list routing if live daemon tests show sender/domain matching is too coarse.
4. Test the daily report manually: `sudo -u mailcat /share/homes/mailcat/mailcat/bin/run_daily_report.sh`, then check `tail -100 /share/homes/mailcat/mailcat/log/daily_report.out` and confirm mail delivery to `hans@australius.nl`.
5. Add the daily report wrapper to QNAP scheduler after the manual test succeeds.
6. Send controlled test messages to `backup@australius.nl` for invoices, clear AI providers, a newsletter/service route, and unmatched mail; verify expected folder moves and daemon logs.
7. Add `List-ID` header support to mailing-list routing if live daemon tests show sender/domain matching is too coarse.
## Persistent File Rule