Symfony Mailgun Mailer

Symfony Mailer bridge for sending email through Mailgun via SMTP, HTTP, or API transports.

SDK
Composer
vv8.1.4
145stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity68
Maintenance80
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture74
Code Quality78
Innovation55
Learning Curve80

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 MailgunTransportFactory supporting mailgun, mailgun+api, mailgun+https, mailgun+smtp, and mailgun+smtps DSN schemes
  • Three transport implementations (MailgunApiTransport, MailgunHttpTransport, MailgunSmtpTransport) selected automatically from the DSN scheme
  • Region-aware configuration via a DSN region option for Mailgun’s US/EU API endpoints
  • A MailgunRequestParser that verifies and parses incoming Mailgun webhook requests into Symfony RemoteEvent objects
  • A MailgunPayloadConverter that 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 region option
  • 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search