Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mailer Laravel Package

symfony/mailer

Symfony Mailer helps you send emails via SMTP and other transports with a clean API. Build Email/TemplatedEmail messages, add attachments and headers, and integrate with Twig templates for HTML rendering. Configure transports via DSN and send reliably.

View on GitHub
Deep Wiki
Context7

Helps sending emails

Frequently asked questions about Mailer
Can I replace Laravel’s built-in Mail facade with Symfony Mailer without breaking existing Mailable classes?
Yes, Symfony Mailer is designed to be SwiftMailer-compatible, so your existing `Mailable` classes will work with minimal adjustments. Replace `Mail::to()->send(new OrderShipped())` with `TemplatedEmail` for templated emails or `Email` for plain messages. The API is nearly identical, so migration is straightforward for most use cases.
Does Symfony Mailer support Laravel’s queue system (e.g., `Mail::later()`) for async email delivery?
Symfony Mailer’s `RoundRobinTransport` or `AsyncTransport` can integrate with Laravel’s queues, but you’ll need to bridge them manually. Use Laravel’s `dispatch()` or `dispatchSync()` to queue the `Mailer::send()` call, then process it via a job. This mimics Laravel’s native async behavior while leveraging Symfony’s transport flexibility.
How do I configure Symfony Mailer to use Laravel’s `.env` settings (e.g., `MAIL_MAILER=smtp`)?
Translate Laravel’s `.env` values into Symfony’s DSN format. For example, `smtp://user:pass@smtp.example.com:587?encryption=tls` mirrors `MAIL_HOST=smtp.example.com`, `MAIL_PORT=587`, and `MAIL_ENCRYPTION=tls`. Use `Transport::fromDsn(env('MAILER_DSN'))` in your service provider to centralize configuration.
Is Symfony Mailer compatible with Laravel 8.x or older projects, or do I need PHP 8.4+?
For Laravel 8.x (PHP 8.1+), use Symfony Mailer **v7.4.x** to avoid PHP 8.4+ requirements. Newer Laravel versions (9.x+) can use v8+. Check your Laravel version’s PHP support first—Symfony Mailer’s v7 branch is stable and widely adopted for legacy projects.
Can I use Blade templates with Symfony Mailer, or is Twig required for templated emails?
Symfony Mailer natively supports Twig via `TemplatedEmail`, but Blade requires a custom `BodyRenderer` adapter. You’ll need to extend Symfony’s `BodyRenderer` to parse Blade templates, which adds ~1–2 days of development. For most teams, Twig integration is simpler and more maintainable.
How does Symfony Mailer’s error handling compare to SwiftMailer in Laravel? Does it work with Laravel Debugbar?
Symfony Mailer’s error handling is robust and integrates with Symfony’s `EventDispatcher` for logging or retries. For Laravel Debugbar, listen to `MessageSentEvent` or `MessageFailedEvent` and log exceptions via Laravel’s `Log` facade. Debugbar’s email panel may need custom instrumentation, but core errors are clearly surfaced.
What transports does Symfony Mailer support out of the box, and can I add custom ones (e.g., Postmark, Brevo)?
Symfony Mailer supports 15+ transports (SMTP, Sendmail, Mailgun, SES, Mailjet, etc.) by default. For unsupported providers like Postmark or Brevo, create a custom `Transport` class implementing `TransportInterface` and register it via `TransportFactory`. The API is designed for extensibility.
Will migrating to Symfony Mailer improve performance for bulk emails or async deliveries in Laravel?
Symfony Mailer’s `RoundRobinTransport` and async capabilities can outperform SwiftMailer in bulk scenarios, but benchmark your specific use case. For Laravel, pair it with queue workers (e.g., `Mail::to()->later()`) to maximize throughput. Async transports reduce blocking, but test with your email volume first.
How do I integrate Symfony Mailer’s EventDispatcher with Laravel’s event system (e.g., trigger `MailSent` events)?
Bridge Symfony’s `EventDispatcher` to Laravel’s events by listening to `MessageSentEvent` and dispatching a Laravel event. Example: `$eventDispatcher->addListener(MessageSentEvent::class, fn($event) => event(new MailSent($event->getMessage())));`. This ensures compatibility with Laravel’s `MailSent` listeners or notifications.
Are there alternatives to Symfony Mailer for Laravel, and why should I choose it over SwiftMailer or Laravel’s built-in Mailer?
Alternatives include Laravel’s native Mailer (SwiftMailer-based) or standalone packages like `spatie/laravel-mail`. Symfony Mailer stands out for its modern API, DSN-based configuration, and native Twig support—ideal if you need async transports, advanced templating, or plan to adopt Symfony components. It’s a drop-in replacement with future-proof features.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony