Bidirectional SMTP ↔ DMail bridge with email threading
Bridge external email to Archon's encrypted DMail system:
- Inbound: SMTP email → encrypted DMail
- Outbound: DMail reply → SMTP email (with proper threading)
alice@gmail.com ←──── SMTP ────→ Bridge ←──── DMail ────→ bob@archon.social
│
└─ Standard email threading
(In-Reply-To, References)
# Install
npm install
# Configure
cp .env.example .env
# Edit .env with your settings
# Build & run
npm run build
npm start
# Test
swaks --to bob@archon.social --server localhost:2525 --from alice@test.com- Email arrives at
bob@archon.social - Bridge resolves
bob→ DID via archon.social API - Creates encrypted DMail, delivers to Bob
- Stores conversation with email threading headers
- Bob sends DMail to bridge identity
- Bridge finds Bob's active conversation
- Sends email to original sender with proper threading
- Email clients thread the conversation automatically
Uses standard email headers — no tokens or special formatting:
| Header | Purpose |
|---|---|
Message-ID |
Unique ID for each message |
In-Reply-To |
Parent message reference |
References |
Full conversation chain |
See .env.example for all options.
Key settings:
SMTP_PORT— Inbound SMTP port (default: 2525)SMTP_DOMAIN— Email domain (default: archon.social)GATEKEEPER_URL— Archon Gatekeeper APIARCHON_PASSPHRASE— Bridge wallet passphraseCONVERSATION_TIMEOUT_DAYS— Auto-cleanup (default: 30)
SQLite with two tables:
- conversations — Tracks (external_email, archon_did) pairs
- messages — Individual messages with threading headers
Automatic garbage collection removes old conversations.
mail.archon.social. A YOUR_IP
archon.social. MX 10 mail.archon.social.
archon.social. TXT "v=spf1 a mx -all"
# Redirect 25 → 2525 (run bridge unprivileged)
sudo iptables -t nat -A PREROUTING -p tcp --dport 25 -j REDIRECT --to-port 2525[Unit]
Description=Archon Mail Bridge
After=network.target
[Service]
Type=simple
User=archon
WorkingDirectory=/opt/archon-mail-bridge
ExecStart=/usr/bin/node dist/index.js
Restart=always
EnvironmentFile=/opt/archon-mail-bridge/.env
[Install]
WantedBy=multi-user.targetsrc/
├── index.ts # Entry point
├── config.ts # Environment config
├── db/
│ ├── schema.ts # SQLite schema
│ ├── conversations.ts
│ └── messages.ts
├── inbound/
│ ├── smtp-server.ts # SMTP listener
│ ├── handler.ts # Email → DMail
│ └── formatter.ts
├── outbound/
│ ├── poller.ts # Watch for replies
│ ├── handler.ts # DMail → Email
│ ├── smtp-client.ts # Send emails
│ └── formatter.ts
└── lib/
└── resolver.ts # name → DID lookup
MIT