Files
second-brain/projects/homelab/guides/mail-deliverability-rdns-relay-guide.md
T
kiskaadee ad4d0435ce
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 7s
infra(validator): phase 1 — structural refactor to single-pass pipeline
- Introduce Document NamedTuple (path, rel, content, validates_frontmatter)
  as the unit of discovery; all inclusion/exclusion policy lives in
  discover_documents() — no check ever calls is_exempt() again.
- Introduce Issue NamedTuple (severity, path, line, message) with
  Severity = Literal['error', 'warning']; line field reserved for Phase 2.
- Replace four independent rglob traversals with a single discovery pass
  that reads each file once.
- Encapsulate all checks as pure functions returning list[Issue] with no
  global state mutation.
- Eliminate the global errors/warnings lists and module-level execution.
- Remove the any('Deprecated' in e ...) reporting smell; per-check
  pass/fail now derived from returned Issue lists, not string inspection.
- Add explicit check registry tuple in main() — the manifest of what
  validation means is now visible at a glance.
- Separate report() function prepares for --format json without redesign.
- Move MERMAID_TYPES to module-level configuration alongside other constants.
- Behavioral specification preserved: exit 0, same error messages.
- Pyright: 0 errors, 0 warnings.

Also fixes two Mermaid edge label parse errors caught by the improved
validator from the previous session:
  projects/magnetflix/README.md: quote |gRPC Event Stream (SSE)|
  projects/homelab/guides/mail-deliverability-rdns-relay-guide.md:
    quote |Encrypted TLS (587)| and |Port 25 (In & Out)|
2026-09-26 05:18:51 -05:00

5.5 KiB

type, project, tags
type project tags
guide homelab
operations
architecture
homelab
email
deliverability
brevo
dns

Mail Deliverability Guide: Solving Dynamic IPs, Missing rDNS (PTR), and Spamhaus PBL

1. The Core Problem: Why Residential IPs Land in Spam

Your concern is 100% accurate: Attempting to send outbound email directly from a residential or dynamic IP to major providers (Gmail, Outlook, Yahoo, Apple) is virtually guaranteed to fail or go to spam.

Here is what receiving mail servers check when a connection arrives on port 25:

  1. Forward-Confirmed Reverse DNS (FCrDNS / PTR):
    • The receiving MTA checks the connecting IP (186.168.147.225) and looks up its PTR record.
    • It expects the PTR to resolve to the server's FQDN (e.g., mail.roadtotech.me), and for mail.roadtotech.me to resolve back to that exact same IP.
    • Residential ISPs do not permit custom PTR configuration on consumer dynamic lines; they either return NXDOMAIN or a generic residential hostname (e.g., cpe-186-168-xxx.isp.net).
  2. Policy Block List (Spamhaus PBL & RBLs):
    • Almost every residential dynamic IP block in the world is pre-emptively listed on Spamhaus PBL (Policy Block List) and similar spam databases.
    • Major providers (Google, Microsoft) query Spamhaus PBL on the connecting IP. If listed, they reject with 550 5.7.1 Service unavailable; Client host [...] blocked using Spamhaus.

2. Inbound vs. Outbound: The Asymmetry of Email

Email delivery is fundamentally asymmetrical:

Direction What Happens Is PTR / rDNS Required? Is Static IP Required?
Inbound (Receiving mail from others) A sender (e.g. Gmail) looks up your MX record (mail.roadtotech.me) and connects to your port 25. NO. Your server never presents PTR; you are the listener. NO. As long as dynamic DNS (Dynu) points mail.roadtotech.me to your current IP, inbound mail arrives normally.
Outbound (Sending mail to others) Your server connects to Gmail's port 25 (gmail-smtp-in.l.google.com). YES. Gmail inspects your connecting IP for valid PTR and PBL status. YES. Sending directly from dynamic residential IP causes immediate rejection.

3. The Proven Solutions

There are two production-grade patterns homelabs use to achieve 10/10 deliverability (zero spam flag) without an enterprise ISP static line:

Stalwart acts as your complete private mail server (storing emails, providing IMAP/JMAP mailboxes to your phone and computer), but uses an authenticated outbound relay (Smart Host) for sending external emails.

flowchart LR
    subgraph Homelab ["Homelab (Dynamic IP)"]
        Client["Email Client<br/>(Thunderbird / Phone)"]
        Stalwart["Stalwart Mail Server<br/>• Stores Mailboxes (IMAP/JMAP)<br/>• Signs with your Domain DKIM"]
    end

    subgraph Outbound ["Smart Host Relay (Static IP + Clean PTR)"]
        Relay["Brevo / Amazon SES<br/>• Static Enterprise IP<br/>• Clean rDNS (PTR)<br/>• SPF: include:spf.brevo.com"]
    end

    subgraph Recipient ["Recipient"]
        Gmail["Gmail / Outlook MTA<br/>Checks: SPF ✓ DKIM ✓ DMARC ✓<br/>Placement: INBOX"]
    end

    Client -->|Submit| Stalwart
    Stalwart -->|"Encrypted TLS (587)"| Relay
    Relay -->|Delivers| Gmail

Why This Gives 100% Inbox Placement:

  1. DKIM: Stalwart signs the outgoing email with your private key for roadtotech.me. The cryptographic signature proves you wrote it.
  2. SPF: Your DNS SPF record includes the relay (v=spf1 mx include:spf.brevo.com ~all).
  3. DMARC: Passes with flying colors because DKIM aligns with roadtotech.me.
  4. Connecting IP: Gmail sees the email coming from the relay's IP (which has clean rDNS and zero PBL listings). Your residential dynamic IP is never exposed or penalized.
  5. Cost:
    • Brevo (Sendinblue): Free tier allows 300 emails/day (9,000/month) with zero cost.
    • Amazon SES: 10,000 emails/month free or $0.10/10k.

Pattern B: The VPS WireGuard Gateway (100% Self-Hosted — ~$3/mo)

If you strictly do not want any third-party relay touching your outbound emails:

flowchart LR
    subgraph Homelab ["Homelab (Dynamic IP)"]
        Stalwart["Stalwart Mail Server"]
    end

    subgraph Cloud ["Cloud VPS ($3/mo - Hetzner / RackNerd)"]
        VPS["VPS Gateway<br/>• Dedicated Static IP<br/>• Custom PTR: mail.roadtotech.me<br/>• WireGuard Tunnel"]
    end

    subgraph Internet ["Public Internet"]
        World["External Mail Servers"]
    end

    Stalwart <==>|Encrypted WireGuard Tunnel| VPS
    VPS <==>|"Port 25 (In & Out)"| World
  1. Rent a cheap cloud VPS (Hetzner Cloud ~$3.50/mo or RackNerd ~$15/yr) that provides a static IPv4 and allows setting custom rDNS (PTR).
  2. Set the VPS PTR record to mail.roadtotech.me.
  3. Establish a WireGuard tunnel between the VPS and your homelab server.
  4. Route port 25 traffic (both inbound and outbound) through the VPS tunnel.

4. Summary & Recommendation

  • If you don't want to pay for or manage a VPS: Pattern A (Stalwart + Free Brevo/SES Outbound Relay) is the gold standard. You get full self-hosted privacy for storage, IMAP, and JMAP, while piggybacking on enterprise deliverability for outbound emails.
  • If you want absolute sovereignty without any intermediary: Pattern B (VPS WireGuard Gateway) gives you a dedicated static IP and custom PTR for ~$3/month.