fix/BIT-33892-imap-logout-oserror
ci / verify (pull_request) Successful in 27s
The finally block in sync_account and retry_single_message only caught
imaplib.IMAP4.error from imap.logout(). When the underlying socket had
already timed out, logout() raises OSError('cannot read from timed out
object') which escaped the handler and crashed the sync run.
Add OSError to the except tuple so cleanup completes cleanly.
Paperclip-BIT-33892
BizDocs Forwarder
Multi-account IMAP → BizDocs forwarder: detect invoice attachments (PDF/XML/ZIP), forward original email via SMTP.
- Repo: https://git.bitreport.pt/BitReport.pt/forwarder
- Paperclip: http://10.10.50.17:3100/BIT/projects/bizdocs-forwarder
Stack
| Component | Path | Description |
|---|---|---|
| API | src/forwarder/api/ |
FastAPI REST |
| Worker | src/forwarder/worker/ |
APScheduler IMAP sync |
| Admin UI | admin-ui/ |
Vite + React |
| DB | MySQL 8 | Alembic migrations |
Quick start
cp .env.example .env
# Generate ENCRYPTION_KEY: python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
docker compose up -d --build
docker compose exec api alembic upgrade head
- API: http://localhost:8000/api/health
- Admin UI: http://localhost:8080
- Auth: HTTP Basic (
ADMIN_USERNAME/ADMIN_PASSWORD)
Local dev
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
docker compose up -d mysql
alembic upgrade head
uvicorn forwarder.api.app:app --reload --app-dir src
forwarder worker # second terminal
cd admin-ui && npm install && npm run dev # third terminal
Deploy (Proxmox CT 243)
Autodeploy: push to main on Gitea → webhook → deploy-hook (:9090) → deploy/deploy-pull.sh → docker compose build && up.
One-time setup (CT)
git clone https://git.bitreport.pt/BitReport.pt/forwarder.git /opt/forwarder
cd /opt/forwarder
cp .env.example .env # or ln -s /etc/forwarder/forwarder.env .env
# Set DEPLOY_WEBHOOK_SECRET in .env (same value as Gitea webhook secret)
export FORWARDER_REPO_DIR=/opt/forwarder
docker compose up -d --build
Gitea webhook
Repo → Settings → Webhooks → Add:
| Field | Value |
|---|---|
| URL | http://10.10.50.43:9090/ |
| Secret | same as DEPLOY_WEBHOOK_SECRET in .env |
| Events | Push |
Test: curl -s http://10.10.50.43:9090/ → {"status":"ok",...}
Deploy logs: /opt/forwarder/storage/deploy-logs/
Manual deploy (emergency only)
cd /opt/forwarder && bash deploy/deploy-pull.sh
Description
BizDocs Forwarder — IMAP-to-BizDocs multi-account forwarder platform (MySQL, API, worker, admin UI)
670 KiB
0 Stars
32 Watchers
0 Forks
Languages
Python
80.9%
TypeScript
16.7%
PHP
0.9%
Shell
0.7%
Dockerfile
0.4%
Other
0.2%