Skip to content

archetech/archon-mail-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archon Mail Bridge

Bidirectional SMTP ↔ DMail bridge with email threading

Overview

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)

Quick Start

# 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

How It Works

Inbound (Email → DMail)

  1. Email arrives at bob@archon.social
  2. Bridge resolves bob → DID via archon.social API
  3. Creates encrypted DMail, delivers to Bob
  4. Stores conversation with email threading headers

Outbound (DMail → Email)

  1. Bob sends DMail to bridge identity
  2. Bridge finds Bob's active conversation
  3. Sends email to original sender with proper threading
  4. Email clients thread the conversation automatically

Threading

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

Configuration

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 API
  • ARCHON_PASSPHRASE — Bridge wallet passphrase
  • CONVERSATION_TIMEOUT_DAYS — Auto-cleanup (default: 30)

Database

SQLite with two tables:

  • conversations — Tracks (external_email, archon_did) pairs
  • messages — Individual messages with threading headers

Automatic garbage collection removes old conversations.

Production Deployment

DNS

mail.archon.social.   A      YOUR_IP
archon.social.        MX  10 mail.archon.social.
archon.social.        TXT    "v=spf1 a mx -all"

Port Redirect

# Redirect 25 → 2525 (run bridge unprivileged)
sudo iptables -t nat -A PREROUTING -p tcp --dport 25 -j REDIRECT --to-port 2525

Systemd

[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.target

Architecture

src/
├── 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

License

MIT

About

dmail-smtp bidirectional bridge - modeled after listserv

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors