Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
relative links - Update all Homelab documents and engineering journals with core tags (`architecture`, `security`, `operations`, `ADR`). - Replace machine-specific `file:///` URLS and absolute local paths with portable relative Markdown links and code backticks. - Align Homelab project landing page and documentation status with current infrastructure topology
8.3 KiB
8.3 KiB
type, project, date, tags
| type | project | date | tags | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| journal | homelab | 2026-09-15 |
|
Complete Self-Hosted Email Infrastructure & Webmail Deployment (Stalwart, LLDAP, Brevo, SnappyMail)
1. Executive Summary
Today we successfully engineered, deployed, and verified a production-grade, zero-cost, self-hosted email infrastructure for roadtotech.me within Homelab Core. The stack bridges modern mail protocols (JMAP, IMAP, SMTP, Sieve) with our existing centralized LLDAP directory, terminates TLS via Traefik, solves residential ISP deliverability through an authenticated Brevo Smart Host relay, and provides a lightweight browser-based webmail client (SnappyMail).
Both inbound direct delivery from Google's MX servers and outbound relay delivery to external Gmail inboxes were tested and verified with 100% deliverability, valid DKIM signatures, and zero spam-flagging.
flowchart TD
subgraph Internet ["Public Internet & DNS (Dynu)"]
GmailIn["External Inbound<br/>(Gmail / Outlook / Proton)"]
GmailOut["External Inboxes<br/>(Gmail Primary Inbox)"]
Brevo["Brevo Outbound Smart Host<br/>smtp-relay.brevo.com:587"]
DNS["Dynu DNS (ns1.dynu.com)<br/>MX, SPF, DKIM1/2, DMARC"]
end
subgraph Router ["Edge Gateway (MitraStar)"]
NAT25["NAT Port 25 -> 192.168.1.36:25"]
NAT443["NAT Port 443 -> 192.168.1.36:443"]
end
subgraph Core ["Homelab Core (server-remote)"]
Traefik["Traefik v3.6 (Reverse Proxy)<br/>Let's Encrypt Wildcard TLS"]
Snappy["SnappyMail Webmail<br/>https://webmail.roadtotech.me"]
Stalwart["Stalwart Mail Server v0.16.22<br/>MTA / IMAP / JMAP / Sieve / RocksDB"]
LLDAP["LLDAP Directory<br/>ldap://lldap:3890"]
Authelia["Authelia SSO<br/>https://auth.roadtotech.me"]
Homepage["Homepage Dashboard<br/>https://dashboard.roadtotech.me"]
end
GmailIn -->|Port 25| NAT25 --> Stalwart
Snappy -->|"Internal IMAPS: 993 / SMTPS: 465"| Stalwart
Stalwart -->|"Auth & JIT Provisioning"| LLDAP
Stalwart -->|"Outbound Relay (Port 587)"| Brevo --> GmailOut
Traefik -->|Port 8888| Snappy
Traefik -->|Port 8080| Stalwart
NAT443 --> Traefik
2. Key Accomplishments & Technical Milestones
A. Authelia Session Extension
- Extended Authelia session and JWT timeouts in
Core/config/authelia/configuration.yml:expiration: 7d(7 days maximum session lifetime).inactivity: 3d(3 days idle timeout).remember_me: 1M(1 month persistent cookie).
- Live cookie header verified:
authelia_session=...; expires=Tue, 22 Sep 2026.
B. Stalwart Mail Server Core Infrastructure
- Deployed Stalwart Mail Server (
stalwartlabs/stalwart:v0.16.22) toCore/docker-compose.ymlonproxy-net. - Port Bindings:
25:25: Standard Inbound SMTP from external MTAs.465:465: SMTPS (Implicit TLS Submission).587:587: SMTP Submission (STARTTLS).993:993: IMAPS (Encrypted IMAP).4190:4190: ManageSieve (Server-side mail sorting).- Internal
8080: Traefik HTTPS routing forhttps://mail.roadtotech.me.
- Persistent Storage:
- Configured RocksDB database under
/var/lib/stalwartmapped to local host directory./config/stalwart/data. - Declared
systemd.tmpfiles.rulesinCore/nixos/modules/homeserver.nixto ensure permanent directory permissions (0777) across machine reboots, rebuilds, or fresh disaster recoveries.
- Configured RocksDB database under
C. LLDAP Directory Integration & JIT Provisioning
- Integrated Stalwart with the internal LLDAP instance (
ldap://lldap:3890):- Base DN:
dc=roadtotech,dc=me. - Bind Authentication: Enabled (
bindAuthentication = true), avoiding cleartext password exposure. - Schema Alignment: Configured user filters for LLDAP's
personobjectClass ((&(objectClass=person)(|(mail=?)(uid=?)))) and groups forgroupOfUniqueNames.
- Base DN:
- Just-in-Time (JIT) Provisioning: Verified that logging in with
kiskaadee@roadtotech.medynamically materializes the mailbox and user profile inside Stalwart without manual pre-provisioning.
D. Deliverability Architecture (Residential IP + Smart Host)
- Problem Solved: Dynamic residential IPs (
PPPoE-Internet) are blocked by default on Spamhaus PBL / Zen and lack custom reverse DNS (PTR) records, causing direct sends to fail or land in spam. - Solution: Integrated Brevo as an authenticated Smart Host outbound relay:
- Secrets encrypted via SOPS in
nixos/secrets.yaml(brevo/smtp_loginandbrevo/smtp_key) and injected into runtime environment templates. - Configured Stalwart MTA Outbound Route
brevopointing tosmtp-relay.brevo.com:587with STARTTLS. - Updated MTA Outbound Strategy: local domains (
roadtotech.me) deliver locally ('local'), while all external recipients route through'brevo'.
- Secrets encrypted via SOPS in
- DNS Records Verified on Dynu (
ns1.dynu.com):MX 10 mail.roadtotech.me.TXT @\rightarrowv=spf1 mx include:spf.brevo.com ~allCNAME brevo1._domainkey\rightarrowb1.roadtotech-me.dkim.brevo.comCNAME brevo2._domainkey\rightarrowb2.roadtotech-me.dkim.brevo.comTXT _dmarc\rightarrowv=DMARC1; p=none; rua=mailto:rua@dmarc.brevo.com- Dynu Quota Optimization: Bypassed Dynu's 4-CNAME free tier limitation by omitting optional marketing tracking subdomains (
send,r.send), keeping all authentication records intact.
E. Webmail Client (SnappyMail) Deployment
- Deployed SnappyMail (
v2.38.2) as a lightweight (~30MB RAM) companion inCore/docker-compose.ymlexposed athttps://webmail.roadtotech.me. - Pre-configured
roadtotech.me.jsondomain profile to communicate internally withstalwart:993(IMAP) andstalwart:465(SMTP). - Added service tiles for both Stalwart Mail and Webmail to the Homepage dashboard at
https://dashboard.roadtotech.me.
3. Verification & Live Testing Results
- Inbound Email:
- Sent test email from external Gmail account (
fcortesbio@gmail.com) tokiskaadee@roadtotech.me. - Router forwarded Port 25
\rightarrow192.168.1.36:25. - Stalwart accepted message, validated recipient, and delivered directly to local mailbox (
queueName = "local"). - Message appeared in SnappyMail inbox.
- Sent test email from external Gmail account (
- Outbound Email:
- Composed reply from
kiskaadee@roadtotech.mein SnappyMail tofcortesbio@gmail.com. - Stalwart routed message through
smtp-relay.brevo.com:587. - Arrived in Gmail primary inbox within minutes.
- Header inspection confirmed:
signed-by: roadtotech.me(DKIM valid)mailed-by: ha.d.sender-sib.com(Brevo authenticated)security: Standard encryption (TLS)- Zero spam flags.
- Composed reply from
4. Operational Runbook & Settings Reference
| Service / Interface | URL / Endpoint | Port(s) | Credentials / Auth |
|---|---|---|---|
| Webmail | https://webmail.roadtotech.me |
443 (HTTPS) | LLDAP Email (kiskaadee@roadtotech.me) + LLDAP Password |
| Stalwart Admin | https://mail.roadtotech.me/account |
443 (HTTPS) | Admin Account / Recovery Admin (admin) |
| Inbound SMTP | mail.roadtotech.me |
25 (TCP) | Unauthenticated / Opportunistic STARTTLS |
| Client IMAP | mail.roadtotech.me |
993 (TCP) | SSL/TLS, LLDAP credentials or App Password |
| Client SMTP | mail.roadtotech.me |
587 (TCP) | STARTTLS, LLDAP credentials or App Password |
| Outbound Relay | smtp-relay.brevo.com |
587 (TCP) | Authenticated Brevo SMTP Login & Key |
5. Next Steps & Future Enhancements
- Authelia Live Password Reset Integration:
- Update
Core/config/authelia/configuration.ymlto replacenotifier: filesystemwithnotifier: smtp(submission://stalwart:587), enabling instant password reset emails for all LLDAP users.
- Update
- Gitea Mailer Configuration:
- Configure
[mailer]in Gitea (Sites/homelab-gitea/) to send commit, issue, and review notifications fromgit@roadtotech.me.
- Configure
- Automated System Alerts:
- Configure Diun (Docker image updates) and backup health scripts to dispatch summary digests to
admin@roadtotech.me.
- Configure Diun (Docker image updates) and backup health scripts to dispatch summary digests to
- Client Autoconfig (RFC 6186 / Mozilla ISPDB):
- Add standard DNS SRV records (
_imaps._tcp.roadtotech.me,_submission._tcp.roadtotech.me) and Autoconfig XML endpoints for zero-touch Thunderbird and Apple Mail setup.
- Add standard DNS SRV records (