Symfony Mailgun Mailer
Symfony Mailer bridge for sending email through Mailgun via SMTP, HTTP, or API transports.
Repository Health
Technical Analysis
Symfony Mailgun Mailer plugs Mailgun into Symfony’s Mailer component by registering mailgun, mailgun+api, mailgun+https, and mailgun+smtp DSN schemes, so applications can switch to Mailgun as an email transport by changing a single MAILER_DSN environment variable rather than writing provider-specific sending code.
Beyond outbound sending, it ships a Webhook request parser and RemoteEvent payload converter, letting Symfony apps consume Mailgun’s delivery, bounce, and complaint webhooks through Symfony’s standard remote-event dispatching instead of custom webhook-handling code.
What You Get
- A
MailgunTransportFactorysupportingmailgun,mailgun+api,mailgun+https,mailgun+smtp, andmailgun+smtpsDSN schemes - Three transport implementations (
MailgunApiTransport,MailgunHttpTransport,MailgunSmtpTransport) selected automatically from the DSN scheme - Region-aware configuration via a DSN
regionoption for Mailgun’s US/EU API endpoints - A
MailgunRequestParserthat verifies and parses incoming Mailgun webhook requests into SymfonyRemoteEventobjects - A
MailgunPayloadConverterthat maps Mailgun’s webhook payload shape into Symfony’s standard mailer event types (delivered, bounced, complaint, etc.)
Common Use Cases
- Sending transactional email from a Symfony app through Mailgun by setting
MAILER_DSN=mailgun+api://KEY:DOMAIN@default - Switching an existing Symfony Mailer setup between SMTP and Mailgun’s HTTP API without changing application code
- Receiving and reacting to Mailgun bounce/complaint webhooks via Symfony’s Webhook and RemoteEvent components
- Selecting Mailgun’s EU region endpoint for GDPR-sensitive email sending via the DSN
regionoption - Building a multi-provider mailer setup where Mailgun is one of several interchangeable transports
Under The Hood
Architecture - MailgunTransportFactory::create() inspects the DSN scheme to instantiate one of three transport classes sharing a common MailgunHeadersTrait for translating Symfony Email headers into Mailgun’s expected format; the Webhook/RemoteEvent directories form a second, independent flow where MailgunRequestParser validates webhook signatures and MailgunPayloadConverter normalizes Mailgun’s event payload into Symfony’s shared RemoteEvent model, keeping outbound sending and inbound event handling decoupled. Tech Stack - PHP 8.4+, depending only on symfony/mailer at runtime, with symfony/http-client and symfony/webhook as dev/optional dependencies for the HTTP transport and webhook parsing paths respectively; distributed as a Composer package split from the main symfony/symfony monorepo via symfony/mailer bridge conventions. Code Quality - A Tests/ directory with PHPUnit configuration (phpunit.xml.dist) covers the transport factory and Mailgun-specific transports; as a first-party Symfony bridge it follows the framework’s strict coding standards, type declarations, and author/license headers on every file. API Design - Configuration is entirely DSN-string driven (mailgun+api://KEY:DOMAIN@default?region=REGION), matching the pattern used by every other Symfony Mailer bridge, so developers already familiar with Symfony’s SMTP or SendGrid bridges get zero-boilerplate familiarity switching to Mailgun.
Used by 4 apps in this directory
Akaunting
Invoicing Finance
Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.
Fleetbase
Logistics
Modular open-source logistics and supply chain operating system
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.