mxhop

SMTP forwarder · Rust · MIT OR Apache-2.0

Mail for your domains, handed to mailboxes you already have.

One static binary. One TOML file. No database, no mailstore, no web interface — mxhop takes a message at the door, works out who it is for, and gives it to Gmail, Fastmail or wherever you already read your mail.

v0.3.0 · everything below is written and tested · one production install so far

$ openssl s_client -starttls smtp -connect mx.example.com:25 -quiet
220 mx.example.com mxhop ready
EHLO sender.example
250-mx.example.com greets sender.example
250-SIZE 26214400
250-8BITMIME
250-PIPELINING
250-STARTTLS
250 ENHANCEDSTATUSCODES
MAIL FROM:<you@sender.example>
250 2.1.0 sender accepted
RCPT TO:<hello@yourdomain.com>
250 2.1.5 recipient accepted
DATA
354 go ahead, end with <CRLF>.<CRLF>
… the message …
250 2.0.0 delivered as 1795110377370-000003-0007

The reply arrives while the sending server still holds the connection. If the destination refuses it, that refusal is what the sender gets — not a bounce an hour later from an address nobody reads.

Three ways in

Same binary behind all of them. Pick the one that matches how you already run things.

Why it's harder than it looks

Forwarding mail is three lines of code and a decade of edge cases. These are the ones that decide whether your mail arrives.

Forwarding breaks SPF

The message now comes from your server, not the sender's. mxhop rewrites the envelope sender into a domain of yours that is allowed to send (SRS), so the destination's check passes — and it decodes the bounces that come back to that address.

Forwarding breaks DKIM alignment

Unless nothing touches the bytes. mxhop prepends its trace and changes nothing else, so the original signature survives and DMARC still passes. When it cannot, an ARC seal records what this hop found out.

Losing a message is worse than sending it twice

The queue is two plain files per message on disk. A message delivered but not removable from the queue goes out again, deliberately: nothing on disk tells that apart from an attempt that never happened.

The one thing mxhop refuses outright is a forgery. A message whose From: domain publishes p=reject and fails DMARC is turned away at the door, while the sending server still holds it:

550 5.7.1 message from paypal.com fails DMARC and that domain asks for failures to be rejected

Forward it instead and it reaches Gmail with your envelope on it. Gmail refuses it, and the refusal counts against your reputation — every time.

What it writes down about your mail

A forwarder sees every message you receive. What it records is a decision, so here it is in full.

In the log

queue idThe one thread through every line about a message
peer, HELOThe connection's facts
envelopeMAIL FROM and the resolved recipients
Message-IDSo a line here matches a line in the destination's log
size, hopsCounts, never content
verdictsSPF, DKIM, DMARC, and the policy in hand
their replyThe destination's own words

Never, in any line

SubjectNot in a log line, not in a metric label
BodyNot a byte of it
HeadersAny the sender wrote, apart from the Message-ID

This is not a promise in prose. A test reads every logging call in the source and fails the build if one of them would print a message's content — so a length has to be computed and named before it is logged, where a reviewer can see it.

What it won't do

Half the value is in what it is not. If one of these is what you need, mxhop is the wrong tool and you should know that now rather than three pages into the documentation.

Honestly: if your provider can forward mail for you in one setting, it can do this without mxhop and without moving your MX record. This exists for when you want the mail to come through a machine you control.