Under the Hood: How MailGuard Routing Works
A technical deep dive into the architecture of private email forwarding. How we hide your identity even when you reply.
Under the Hood: How MailGuard Routing Works
MailGuard isn't just a forwarder. It's an intelligent firewall for your inbox.
Traditional forwarding is simple: A -> B.
Privacy-preserving forwarding with Reply Masking ("Magic Reply") is a complex orchestration of cryptography, temporary tokens, and edge computing.
This article peels back the layers to show how we process emails in milliseconds without ever storing your data on a disk.
The One-Way Trip (Inbound)
When someone sends an email to your alias (vendor@your-domain.com), the goal is to get it to your real inbox (real@gmail.com) while stripping away tracking pixels and analyzing for threats.
The "Magic" Reply-To Header
The most critical step above is Rewriting the Reply-To.
We don't just pass the sender's email (bad-guy@spam.com) as the reply address. If we did, when you hit "Reply," you would be emailing them directly from your real Gmail, exposing your identity.
Instead, we generate a cryptographic token.
Original Reply-To: bad-guy@spam.com
Rewritten Reply-To: reply+<encrypted_token>@mailguard-system.com
This token contains:
- The original sender's address.
- The alias used (
vendor@). - An expiration timestamp.
- A signature to prevent tampering.
The Return Trip (Outbound / Magic Reply)
When you hit "Reply" in Gmail, you are technically emailing the MailGuard System, not the stranger. This allows us to intercept the message and swap identities.
- Ingestion: You execute a reply. To Google, you are emailing
mailguard-system.com. - Decryption: Our worker receives
reply+<token>. It uses our private key to decrypt the payload. - Masquerading: We reconstruct the email.
- From:
vendor@your-domain.com(Your Alias) - To:
bad-guy@spam.com(Original Sender)
- From:
- Authentication: This is the hard part. To send as
your-domain.com, we must satisfy SPF and DKIM. Because you added our records to your DNS during setup (see our Setup Guide), we are authorized to cryptographically sign this message. - Delivery: The bad guy receives a reply from your alias. They have no way of knowing your real Gmail address even exists.
Privacy By Design: Ephemeral Processing
A core tenet of MailGuard is Zero Persistence.
- We do not store the body of your emails in a database.
- We process the text stream in memory (RAM) at the Edge (Cloudflare Workers).
- Once the forward command is issued, the RAM is cleared.
The only things we store in our database are metadata for your dashboard:
- "Email received for alias X at [Time]."
- "Email blocked for alias Y (Reason: Rule)."
This architecture ensures that even if our database were leaked, your private conversations would remain private, because they simply aren't there.