Symfony Mailer

A PHP component for composing and sending email

Library
Composer
vv8.1.2
1,594stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity96
Maintenance100
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture83
Code Quality85
Innovation70
Learning Curve78

Symfony Mailer is the official email-sending component of the Symfony framework, providing a transport-agnostic API for composing and delivering messages. Transports are configured via simple DSN strings, letting an application switch between SMTP, sendmail, or any of the numerous third-party API-based transports (Mailgun, Postmark, SendGrid, and others via bridge packages) without changing application code.

Built on top of symfony/mime for message construction, Mailer adds failover and round-robin transport strategies for reliability, an event system for hooking into the send lifecycle, and optional integration with Symfony Messenger for asynchronously dispatching emails through a message queue instead of sending them inline.

What You Get

  • A fluent Email message API (via symfony/mime) supporting text/HTML bodies, attachments, and headers
  • DSN-based transport configuration (smtp://, sendmail://, or third-party API transports via bridge packages)
  • Failover and round-robin transport wrappers for delivery reliability across multiple providers
  • An event system (MessageEvent, EventListener/) for hooking into message preparation and sending
  • Optional Symfony Messenger integration to send emails asynchronously through a message queue
  • Twig integration (via symfony/twig-bridge) for rendering HTML email templates

Common Use Cases

  • Sending transactional emails (password resets, order confirmations) from a Symfony or standalone PHP application
  • Switching email providers (SMTP to a third-party API) by changing a DSN string rather than application code
  • Queuing outbound email through Symfony Messenger to avoid blocking HTTP request/response cycles
  • Building failover-resilient email delivery across multiple SMTP or API transports

Under The Hood

Architecture - The component centers on Mailer.php/MailerInterface.php, which accepts a TransportInterface implementation and an Envelope (sender/recipient metadata) to send a RawMessage. Transport/ contains the transport abstraction layer — AbstractTransportFactory, AbstractHttpTransport, AbstractApiTransport as base classes that concrete bridge packages (Mailgun, Postmark, etc.) extend — plus built-in SmtpTransportFactory-backed transports, FailoverTransport, and RoundRobinTransport for multi-transport reliability strategies. EventListener/ and Event/ implement the send-lifecycle hooks, and Messenger/ provides the SendEmailMessage integration for async dispatch via Symfony’s Messenger component.

Tech Stack - Requires PHP 8.4.1+ and depends on symfony/mime for message construction, egulias/email-validator for RFC-compliant address validation, psr/event-dispatcher and psr/log for its event and logging integration, and optionally symfony/http-client/symfony/messenger for HTTP-based transports and async dispatch respectively — all following PSR interfaces to stay framework-agnostic where reasonable.

Code Quality - As one of Symfony’s individually-released components (split from the symfony/symfony monorepo), it inherits Symfony’s strict backward-compatibility policy and semantic versioning discipline, with a Tests/ directory covering transports, DSN parsing, and message assembly. DataCollector/ provides Symfony profiler integration for debugging sent emails in development, showing attention to developer experience beyond the core sending logic.

API Design - The primary flow — Transport::fromDsn() then new Mailer($transport) then $mailer->send($email) — is deliberately terse for the common case, as shown directly in the README. The DSN-based transport configuration is the standout design choice: switching from SMTP to a hosted email API requires changing one string rather than any code, which is a significant developer-experience win for provider migrations.

Used by 6 apps in this directory

PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

754

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
47
Repo Health
66
Technical
66
Dependency
Built with
PHP63%
Vue18%
Gherkin13%
Updated 2 months ago
PHP
66%
AGPL 3.0

EspoCRM

Marketing · Ecommerce · CRM

3,259

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
64
Dependency
Built with
PHP66%
JavaScript24%
Updated yesterday
PHP
85%
Other

Invoice Ninja

Invoicing Finance · Project Management

10,008

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.

View details
97
Repo Health
83
Technical
62
Dependency
Built with
PHP85%
XSLT10%
Updated 2 days ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

4,918

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
63
Dependency
Built with
PHP86%
Updated today
PHP
82%
Other

Mautic

Automation · Marketing · Ecommerce

10,366

The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.

View details
98
Repo Health
76
Technical
64
Dependency
Built with
PHP82%
Updated yesterday
PHP
84%
MIT

wallabag

Bookmarks Archiving

12,917

Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.

View details
92
Repo Health
81
Technical
59
Dependency
Built with
PHP84%
Twig13%
Updated yesterday

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