Tor SMTP Gateway (svc-net-tor-smtp)ΒΆ
DescriptionΒΆ
A small SMTP relay that carries .onion recipients over Tor. The active mail
provider (Stalwart) cannot open a SOCKS connection of its own, and a .onion
address cannot be reached any other way, so the provider hands every .onion
recipient to this gateway as an ordinary SMTP relay target and the gateway dials
<recipient-domain>:25 through Torβs SOCKS5 listener.
OverviewΒΆ
Stalwart ββ(relay route: rcpt ends_with .onion)βββΆ tor-smtp:1525
tor-smtp ββ(SOCKS5, remote DNS)βββΆ Tor βββΆ <recipient>.onion:25
Clearnet mail is untouched β it stays on the providerβs normal MX delivery. The
gateway only ever accepts .onion recipients; it is not an open relay.
CosmosΒΆ
The diagram places Tor SMTP Gateway (svc-net-tor-smtp) in the Infinito.Nexus cosmos: the components it deploys (capabilities), the central services it consumes (dependencies), and its outward reach (federation and bridged external networks).
flowchart LR
subgraph role [svc-net-tor-smtp π³π]
svc_tor_smtp["tor-smtp"]
end
subgraph dependents [Dependents]
dpt_web_app_stalwart["web-app-stalwart π³π"]
end
svc_tor_smtp -. "0..1" .-> dpt_web_app_stalwart
Solid 1:1 edges are fixed relationships; dashed 0..1 edges are conditional (enabled only in matching deployments); red 0..0 edges are turned off in this role. Node markers show the roleβs deploy modes (π» host, π³ compose, π swarm); β marks a service that is explicitly turned off, and βοΈ an Ansible role dependency declared in meta/main.yml.
FeaturesΒΆ
Onion-only relay: accepts a recipient only when its domain ends with
.onion; every clearnet recipient is refused with550.Remote resolution: dials through Torβs SOCKS5 with
proxy_rdns, so the.onionname is resolved by Tor and never looked up locally.One hop per domain: recipients sharing a
.oniondomain are delivered in a single SMTP transaction.Clearnet untouched: normal SMTP reputation, DKIM and SPF delivery never pass through Tor.
Quick SetupΒΆ
DevelopmentΒΆ
Clone, set up the workstation, and deploy Tor SMTP Gateway (svc-net-tor-smtp) onto the local stack:
git clone https://github.com/infinito-nexus/core.git
cd core
make onboard
make compose-deploy mode=reinstall apps=svc-net-tor-smtp full_cycle=false
ProductionΒΆ
Run the published image to provision the inventory and deploy Tor SMTP Gateway (svc-net-tor-smtp) to a managed server (the mounted volume persists the inventory):
APP=svc-net-tor-smtp
HOST=<your-server>
DOMAIN=<your-domain>
TLS_MODE=self_signed
SSH_PUBLIC_KEY="<your-ssh-public-key>"
docker run --rm -it \
-v "$PWD/inventories:/etc/infinito.nexus/inventories" \
-e APP="$APP" -e HOST="$HOST" -e DOMAIN="$DOMAIN" -e TLS_MODE="$TLS_MODE" -e SSH_PUBLIC_KEY="$SSH_PUBLIC_KEY" \
ghcr.io/infinito-nexus/core/debian bash -c '
INVENTORY=/etc/infinito.nexus/inventories/production
infinito administration inventory provision "$INVENTORY" \
--inventory-file "$INVENTORY/devices.yml" \
--host "$HOST" \
--include "$APP" \
--vars "{\"TLS_MODE\": \"$TLS_MODE\", \"DOMAIN_PRIMARY\": \"$DOMAIN\", \"users\": {\"administrator\": {\"authorized_keys\": [\"$SSH_PUBLIC_KEY\"]}}}" &&
infinito administration deploy dedicated "$INVENTORY/devices.yml" \
--password-file "$INVENTORY/.password" \
--diff -vv'
Design DecisionsΒΆ
A dedicated role, not Stalwart config. Stalwart has no outbound SOCKS support (stalwartlabs/stalwart#644), so the Tor hop lives in a separate service that only the
.onionroute uses.proxy_rdnsis on. A.onionhas no DNS entry, so Tor must resolve it β the name is never resolved locally.Co-located with
svc-net-tor. It dials that roleβs SOCKS listener, so it is manager-pinned like the Tor daemon.
CreditsΒΆ
Implemented by Alejandro Roman Ibanez. Part of the Infinito.Nexus Project and maintained by Kevin Veen-Birkenbach. Licensed under the Infinito.Nexus Community License (Non-Commercial).