home / work / postgun

Open source

Postgun

Open-source mass email through your own Mailgun account, with a different file for each recipient: every attendee, customer, or student gets their own certificate, invoice, or ticket in one send.

Role
Designed and built it end to end; published by CodeX Technologies
Stack
  • Next.js 16 / React 19
  • TypeScript
  • Tailwind CSS 4
  • MariaDB / Drizzle ORM
  • Node.js worker
  • Unlayer / Monaco
  • PayPal
  • Docker

The problem

Sending the same email to a few hundred people is easy. Sending each of them a different file isn't. Event organizers, trainers, and schools hand out certificates; businesses send invoices and tickets. Most campaign tools can't attach a personal file to each recipient, so the job ends up as a mail-merge script or an afternoon of manual sends.

Teams that already pay for Mailgun have a second problem: the usual campaign tools want you on their sending infrastructure and charge per contact on top of what Mailgun already costs.

What it is

Postgun is an open-source web app for sending mass email campaigns through your own Mailgun account. You connect your API key, sending domain, and region (US or EU), import a list from CSV or Excel, and design the email in a drag-and-drop builder or raw HTML. Every column in the list becomes a merge tag, like {{name}}.

The feature it's built around is per-recipient attachments. You upload the files (or a ZIP), and Postgun matches each row of the spreadsheet to its own file by a name pattern such as certificate {{order}}.pdf, optionally renaming it on the way out. Every recipient gets their own document in one send.

I designed and built it end to end, and released v1.0.0 under AGPL-3.0 on December 3, 2026. It runs as a hosted service at postgun.codextech.org, published by CodeX, with a free plan, and anyone can self-host it with no limits.

  • Campaign designer: the Unlayer drag-and-drop builder or raw HTML in a Monaco editor, with live preview and test sends.
  • Lists: CSV, Excel (.xlsx), and text import; any column can be a merge tag.
  • Background sending: up to 500 recipients per Mailgun request, with retries and backoff. Campaigns can be paused, resumed, cancelled, or retried while progress updates live.
  • Deliverability basics: an unsubscribe link and an RFC 8058 one-click List-Unsubscribe header on every email, bounces and complaints synced from Mailgun and skipped before each send, and optional sender address rotation for large campaigns.
  • Multi-user: accounts, plans and quotas, and an admin panel with an audit log.

Decisions that shaped it

Two processes, one codebase. The web app never sends campaign mail itself; it only changes a campaign's status. A separate Node.js worker claims each campaign with an atomic database lock, sends a heartbeat on every chunk, and picks up where it left off after a crash or a redeploy. Both ship in one Docker image.

A quota ledger that can't be overshot. Quota is reserved before each chunk goes out and refunded for the recipients that fail, so two campaigns running in parallel can't add up to more than the monthly limit.

Stateless one-click unsubscribe. Unsubscribe links carry an HMAC-signed token, so there's no lookup table to keep in sync, and the one-click POST endpoint follows RFC 8058, which mailbox providers now expect from bulk senders.

Security by default. Mailgun API keys are encrypted at rest with AES-256-GCM. Sessions are JWTs that can be revoked everywhere at once, sign-in is throttled per IP and per email, and every database query is scoped to its user.

Billing is optional. The hosted version takes payments through PayPal Subscriptions and Orders, with verified webhooks. With no PayPal credentials set, the same code runs as an unlimited self-hosted install with no billing UI at all, so self-hosters never see a paywall to work around.

Who it's for

People sending certificates to hundreds of participants, businesses emailing invoices or tickets in bulk, teams already on Mailgun who want a campaign UI without paying a second provider per contact, and developers who want an email campaign tool they can read and modify.

The code is on GitHub, and release notes are in the changelog. Issues and pull requests are welcome.

← All work