Skip to content

Mail Poller → Z2 Deployment Status

Date: 2026-06-11 Status: DEPLOYED — Live on ct102, systemd timer active (15-min interval)


Deployment Summary

ComponentStatusDetail
mail-poller.pyDeployed/opt/hinata/mail-poller/mail-poller.py on ct102
CredentialsCopiedAll 5 files from ct103 (Vaultwarden) → ct102 /opt/itachi/credentials/ (0600)
systemd timerActivehinata-mail-poller.timer enabled, 15-min interval
StateSeededstate.json seeded to current time — only new messages polled
Dry-run testPassedAll 4 accounts connected, tokens refreshed, 0 errors
deploy.shDeletedRemoved 2026-06-11 (dead-script law); deploy via manual pct push

Accounts

AccountProtocolTest Result
michael.asolo1@gmail.comIMAP (imaplib)Connected, 14,702 msgs in INBOX
michael.asolo@hotmail.co.ukGraph APIToken refreshed, 999 msgs found
michael.nnamah@outlook.comGraph APIToken refreshed, 999 msgs found
n.nnamah@outlook.comGraph APIToken refreshed, 899 msgs found

Architecture

  • Runtime: Python 3.11.2, stdlib only (imaplib + urllib)
  • Container: ct102 (Debian 12 bookworm)
  • Credentials: Copied from ct103 /opt/itachi/credentials/
  • State: /opt/hinata/mail-poller/state.json
  • Archive: /opt/hinata/mail-poller/archive/{account}/{YYYY}/{MM}/{hash}.json
  • Timer: systemd hinata-mail-poller.timer (OnBootSec=2min, OnUnitActiveSec=15min)

Bugs Fixed During Deploy

  1. Gmail credential format: mail_imap_credential.json is a list wrapping a dict — added [0] unwrap
  2. Graph API public client: App registration has no client_secret — made it optional in token refresh
  3. OAuth scope: Updated to Mail.Read Mail.ReadWrite offline_access to match granted scopes
  4. Dry-run IMAP: Was downloading all messages in dry-run — added early-exit to just report counts
  5. deploy.sh pct push bug (historical): Used Mac-local path as source — fixed to SCP→Z2 first, then pct push. deploy.sh deleted 2026-06-11

Monitoring Commands

bash
# Timer status
ssh z2 'pct exec 102 -- systemctl status hinata-mail-poller.timer'

# Recent logs
ssh z2 'pct exec 102 -- journalctl -u hinata-mail-poller.service -n 50'

# Polling state
ssh z2 'pct exec 102 -- cat /opt/hinata/mail-poller/state.json'

# Archived emails
ssh z2 'pct exec 102 -- find /opt/hinata/mail-poller/archive -name "*.json" | wc -l'