Show HN: Posthorn, self-hosted mail without the mail server

Hacker News Top Tools

Summary

Posthorn is a self-hosted outbound mail gateway that unifies email sending from multiple apps through a single interface, supporting HTTP and SMTP ingestion with multiple provider transports.

Introducing Posthorn, a self hosted email gateway. One docker container (or Go binary) between every self hosted app on your VPS and your transactional email provider. Set up Posthorn once, point your apps to it, done.<p>I was trying to deploy Ghost on a DigitalOcean droplet and found that DO and many different VPS services have started to block the default SMTP ports to try to combat the various types of abuse they get. To actually configure my app, I had to hack together a Postfix relay.<p>In another project, I had a static site which had a contact form, but my free Formspree account was occasionally hitting usage limits and I desperately wanted some of the anti-spam features they had gated behind their paid accounts so I put together a caddy module to catch HTTP POSTs and bounce them to my provider.<p>I kept bumping into these same email issues. Many of the services I wanted to host (Gitea, Mastodon, Umami, Comentario) ran into the same limitations. This felt like a really common issue that had no good solution.<p>Posthorn is what I built to solve this. It&#x27;s a small Go binary (or 10 MB docker image) that sits between your self hosted apps and your transactional email provider of choice (shipping with support for Postmark, Resend, Mailgun, Amazon SES or an outbound SMTP relay). It also accepts POSTs from HTML forms to support static site needs while adding security layers such as honeypot fields, origin checks and IP rate limiting. There&#x27;s also a JSON HTTP API that supports Bearer auth for backend scripts or cron jobs that just want a &#x2F;send endpoint.<p>I now use this personally in multiple scenarios and I&#x27;ve spent a lot of time beating this up and testing against what I can validate. I&#x27;d love to hear how this might be useful for you, what breaks and any feedback you might have. It&#x27;s open source under Apache 2.0 and I&#x27;d love contributions. I&#x27;m planning to support and grow this for the long haul.<p>Code: <a href="https:&#x2F;&#x2F;github.com&#x2F;craigmccaskill&#x2F;posthorn" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;craigmccaskill&#x2F;posthorn</a><p>Docs: <a href="https:&#x2F;&#x2F;posthorn.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;posthorn.dev&#x2F;</a><p>Longer write up: <a href="https:&#x2F;&#x2F;craigmccaskill.com&#x2F;introducing-posthorn&#x2F;" rel="nofollow">https:&#x2F;&#x2F;craigmccaskill.com&#x2F;introducing-posthorn&#x2F;</a><p>Previous HN discussion on the exact issue I&#x27;m trying to solve: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43620318">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43620318</a>
Original Article
View Cached Full Text

Cached at: 05/27/26, 07:00 AM

craigmccaskill/posthorn

Source: https://github.com/craigmccaskill/posthorn

Posthorn

CI Docs License: Apache-2.0 Go version

The unified outbound mail layer for self-hosted projects. One gateway between every app you self-host and the transactional mail provider you’ve already picked. Three ingress shapes (HTTP form, HTTP API, SMTP), five transports (Postmark, Resend, Mailgun, AWS SES, outbound-SMTP relay), single Go binary, single TOML config.

Real-world stacks: Hugo + Comentario · Ghost · Gitea · Umami digest cron · Cloudflare Worker

Why

Nobody wants to run a mail server in 2026. Self-hosted operators use Postmark, Resend, Mailgun, or AWS SES because they’re cheap, they handle deliverability properly, and someone else worries about SPF / DKIM / DMARC / bounces / sender reputation.

But every app you self-host has to integrate with that service independently. Your contact form. Your Ghost blog’s admin emails. Your Gitea magic links. Your Mastodon notifications. The Cloudflare Worker that fires a password-reset email when someone clicks the link. Each one needs its own copy of the API key, its own integration code, its own quirks around retry and bounce handling. The same outbound concern duplicated across your stack.

And on cloud hosts that block outbound SMTP — DigitalOcean, AWS Lightsail, Linode, Vultr — the SMTP-only apps don’t work at all without a workaround.

Posthorn is the bridge. One container, one config, one set of credentials. Your apps point at Posthorn. Posthorn talks to your provider.

Where your app connectsWhat Posthorn does
HTTP form (contact forms, signups, alert webhooks)Honeypot + Origin/Referer + rate limit + optional CSRF; templates the email; sends
HTTP API mode (workers, cron, payment handlers, internal services)Authorization: Bearer auth; JSON body; idempotent retries; per-request to_override for transactional sends
SMTP listener (Ghost, Gitea, Mastodon, Matrix, NextCloud, Authentik, anything that emits SMTP)AUTH PLAIN or client-cert; STARTTLS-required; sender + recipient allowlists; parses MIME; forwards via HTTP API transport

All three ingresses converge on one transport.Message and one outbound provider — pick from Postmark, Resend, Mailgun, AWS SES, or an outbound-SMTP relay.

What Posthorn is not

To save you a wrong turn:

What it doesLook at instead
Not a mail serverNo mailbox storage, no IMAP/JMAP, no DKIM key management, no MX targetStalwart, Mailcow, iRedMail
Not its own outbound infrastructurePosthorn relays through a provider you chose; it doesn’t run its own SMTP fleet or manage IP reputationPostal, Hyvor Relay
Not a marketing email platformNo list management, no segmentation, no campaign dashboardListmonk
Not webmail / a mailbox UINo interface for reading mailRoundcube, Snappymail (with a mail server)

The wedge is the integration layer between your self-hosted apps and the transactional provider you’ve already picked.

Documentation

posthorn.dev — getting started, configuration reference, deployment guides, feature deep-dives, security model, HTTP API reference, FAQ. Ten recipes covering contact forms, newsletter signups, multi-form sites, monitoring alerts, Cloudflare Workers, internal SMTP relay (Docker Compose), and full case studies for Hugo+Comentario, Ghost, Gitea, and self-hosted Umami digests.

For project history and the v1.0 spec, see spec/.

Quick start (Docker)

# docker-compose.yml
services:
  posthorn:
    image: ghcr.io/craigmccaskill/posthorn:latest
    restart: unless-stopped
    volumes:
      - ./posthorn.toml:/etc/posthorn/config.toml:ro
    environment:
      POSTMARK_API_KEY: ${POSTMARK_API_KEY}
    ports:
      - "127.0.0.1:8080:8080"   # bind to loopback; reverse-proxy from your front door
# posthorn.toml
[[endpoints]]
path = "/api/contact"
to = ["[email protected]"]
from = "Contact Form <[email protected]>"
honeypot = "_gotcha"
allowed_origins = ["https://example.com"]
required = ["name", "email", "message"]
subject = "Contact from {{.name}}"
body = """
From: {{.name}} <{{.email}}>

{{.message}}
"""
redirect_success = "/thank-you"

[endpoints.transport]
type = "postmark"

[endpoints.transport.settings]
api_key = "${env.POSTMARK_API_KEY}"

[endpoints.rate_limit]
count = 5
interval = "1m"

Reverse-proxy /api/contact from your front door (Caddy, nginx, Traefik) to http://posthorn:8080. Point your form’s action at /api/contact. Done.

Full walkthrough: posthorn.dev/getting-started/quick-start.

API mode (server-to-server)

For Workers, cron jobs, internal services — anything that speaks JSON instead of forms:

[[endpoints]]
path = "/api/transactional"
to = ["[email protected]"]
from = "YourApp <[email protected]>"
auth = "api-key"
api_keys = ["${env.WORKER_KEY_PRIMARY}", "${env.WORKER_KEY_BACKUP}"]
required = ["subject_line", "message"]
subject = "{{.subject_line}}"
body = "{{.message}}"

[endpoints.transport]
type = "postmark"

[endpoints.transport.settings]
api_key = "${env.POSTMARK_API_KEY}"
curl -X POST https://posthorn.yourdomain.com/api/transactional \
  -H "Authorization: Bearer $WORKER_KEY_PRIMARY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: reset:user-123:$(date -u +%FT%H)" \
  --data '{
    "to_override": "[email protected]",
    "subject_line": "Reset your password",
    "message": "Click here: https://app.example.com/reset/abc"
  }'

Full walkthrough: posthorn.dev/recipes/cloudflare-worker.

SMTP listener (Ghost / Gitea / Mastodon / Authentik)

For apps that speak SMTP natively and can’t be reconfigured to call an HTTP API:

[smtp_listener]
listen          = ":2525"
require_tls     = true
tls_cert        = "/etc/posthorn/cert.pem"
tls_key         = "/etc/posthorn/key.pem"
auth_required   = "smtp-auth"
allowed_senders = ["*@yourdomain.com"]
max_recipients_per_session = 10
max_message_size = "1MB"

[[smtp_listener.smtp_users]]
username = "ghost"
password = "${env.GHOST_SMTP_PASSWORD}"

[smtp_listener.transport]
type = "postmark"

[smtp_listener.transport.settings]
api_key = "${env.POSTMARK_API_KEY}"

Point Ghost (or any app’s SMTP config) at posthorn.yourdomain.com:2525 with the username/password above. Posthorn parses the MIME, builds a transport.Message, forwards via Postmark.

Full doc: posthorn.dev/features/smtp-ingress.

Picking a transport

TransportBest forAuthBody
PostmarkTransactional email, strong deliverability defaultsX-Postmark-Server-TokenJSON
ResendModern HTTP API, developer-friendly dashboardAuthorization: BearerJSON
MailgunHigher-volume transactional, US + EU regionsHTTP Basicmultipart/form-data
AWS SESAWS-native deployments, cheapest at volumeAWS SigV4 (bespoke)JSON
Outbound SMTPAny STARTTLS-capable relay (Mailtrap, your Postfix smarthost, etc.)AUTH PLAINSMTP DATA

Switching providers is a TOML edit — every transport implements the same Transport interface. See posthorn.dev/configuration/transports for per-provider config.

Production checklist

Before pointing real traffic at Posthorn:

  1. DNS — SPF, DKIM, and DMARC records on your sending domain. Without these your mail goes to spam. See posthorn.dev/security/dns.
  2. Reverse proxy — Posthorn does not terminate TLS. Run it behind Caddy, nginx, or Traefik. See posthorn.dev/deployment/reverse-proxy.
  3. allowed_origins (form-mode endpoints) — set this to lock submissions to your domain. Without it, anyone can POST to your endpoint.
  4. rate_limit — set a tight bucket per endpoint (5/minute is a sensible default for a public contact form; API mode rate-limits per matched key).
  5. trusted_proxies — if behind a reverse proxy, list its CIDR (or use the cloudflare named preset) so the rate limiter sees the real client IP.
  6. /healthz and /metrics — auto-registered on the same listener. Wire your Docker healthcheck or Prometheus scrape to these.

The full operator checklist is on posthorn.dev.

What’s in v1.0

BlockDetail
Form ingressForm-encoded + multipart bodies; honeypot, Origin/Referer fail-closed, rate limit, optional CSRF tokens
API modeauth = "api-key" with Bearer tokens (constant-time compare); JSON content type; idempotency keys (24h, in-memory LRU); per-request to_override
TransportsPostmark, Resend, Mailgun, AWS SES (bespoke SigV4), outbound-SMTP relay
SMTP listenerTCP listener with AUTH PLAIN / client-cert, STARTTLS-required, sender + recipient allowlists, size cap, MIME → transport.Message
Operations/healthz, /metrics (Prometheus exposition), dry-run mode, IP-stripping, named trusted_proxies presets (Cloudflare)
Failure handling1 retry on transient/5xx (1s), 1 retry on 429 (5s), 10s hard timeout
LoggingStructured JSON; UUIDv4 submission IDs and SMTP session IDs; transport_message_id in submission_sent
DeploymentSingle Go binary, multi-arch distroless Docker image at ghcr.io/craigmccaskill/posthorn

Three external Go dependencies in the whole module: TOML parser, UUID library, LRU cache. Every transport is bespoke — no vendor SDK in transport code.

Roadmap

v2 — platform maturity. SQLite submission log, retry queue across restarts, suppression list (auto on hard bounces), durable idempotency, lifecycle event callbacks via HMAC-signed webhook, RFC 8058 one-click unsubscribe, file attachments, HTML body, multiple outputs per endpoint (email + webhook + log fan-out), multi-tenant SMTP routing.

v3 — speculative. Admin UI, proof-of-work spam challenge, PGP encryption. Depends on community traction.

Full trajectory: posthorn.dev/roadmap.

Build from source

Requires Go 1.25+.

git clone https://github.com/craigmccaskill/posthorn
cd posthorn/core
go build -o /tmp/posthorn ./cmd/posthorn
/tmp/posthorn version

Contributing

The v1.0 specification is in spec/ (brief, PRD, architecture). The architecture doc at spec/03-architecture.md is the source of truth for design questions.

Security issues: see SECURITY.md — do not open public issues for security disclosures.

License

Apache-2.0. See LICENSE.

Similar Articles

Show HN: E2a – Open-source email gateway for AI agents

Hacker News Top

E2a is an open-source email gateway that enables AI agents to securely send and receive emails via webhooks, WebSockets, or HTTP APIs, featuring SPF/DKIM verification, TypeScript and Python SDKs, and optional human-in-the-loop approval.

knadh/listmonk

GitHub Trending (daily)

listmonk is a standalone, self-hosted newsletter and mailing list manager that is fast, feature-rich, and packed into a single binary using a PostgreSQL database.

Hookdeck Outpost

Product Hunt

Hookdeck Outpost is an open-source outbound webhook solution for platforms.