Re-send the received RFC822 message with normal Fwd headers (To, From, Subject). The previous code wrapped the message in message/rfc822 with filename original-email.eml, which the relay rejected.
77 lines
2.1 KiB
Markdown
77 lines
2.1 KiB
Markdown
# 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
|
|
|
|
```bash
|
|
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
|
|
|
|
```bash
|
|
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)
|
|
|
|
```bash
|
|
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)
|
|
|
|
```bash
|
|
cd /opt/forwarder && bash deploy/deploy-pull.sh
|
|
```
|