josbeir/cakephp-symfony-mailer provides a CakePHP 5 mail transport that hands CakePHP's rendered MIME messages to Symfony Mailer.
CakePHP remains responsible for rendering the message. Symfony Mailer is responsible for delivery, so multipart alternatives, attachments, inline cid: images, and CakePHP headers are preserved.
Keep CakePHP's mailer API, templates, localization, and MIME composition while gaining Symfony Mailer's transport ecosystem:
- Use provider bridges and HTTP API transports for services such as Mailgun, Amazon SES, Postmark, and SendGrid.
- Switch between Mailpit or SMTP locally and an API-backed provider in production through configuration alone.
- Configure Symfony's failover and round-robin transports without changing application mailers.
- Preserve multipart text/HTML messages, attachments, inline
cid:images, custom headers, and envelope recipients. - Keep delivery concerns out of application mailers: CakePHP builds the message and Symfony Mailer delivers it.
This bridge delegates transport selection and delivery to Symfony Mailer. See the Symfony Mailer documentation for DSN syntax, built-in transports, TLS settings, failover, and round-robin delivery.
For provider-backed delivery, see Using a 3rd-party transport. Install the provider bridge for the mailer you choose. API-based transports also require Symfony's symfony/http-client package; provider bridges do not necessarily install that optional HTTP client themselves. SMTP, Sendmail, and Native transports do not need it. This plugin remains provider-agnostic and supports any transport accepted by Symfony Mailer.
Symfony Mailer provides provider bridges for commonly used services including:
| Mailer | Symfony bridge |
|---|---|
| AhaSend | symfony/aha-send-mailer |
| Amazon SES | symfony/amazon-mailer |
| Azure Communication Services | symfony/azure-mailer |
| Brevo | symfony/brevo-mailer |
| Mailgun | symfony/mailgun-mailer |
| Mailjet | symfony/mailjet-mailer |
| MailerSend | symfony/mailer-send-mailer |
| Mailtrap | symfony/mailtrap-mailer |
| Microsoft Graph | symfony/microsoft-graph-mailer |
| Postmark | symfony/postmark-mailer |
| Resend | symfony/resend-mailer |
| SendGrid | symfony/sendgrid-mailer |
Symfony also includes built-in smtp, sendmail, and native transports. The provider list changes over time; consult the Symfony provider table for the complete, current list and each provider's DSN format. Gmail's transport is intended as a convenience for development and testing, not as a production delivery service.
- PHP 8.2 or newer
- CakePHP 5.2 or newer
- Symfony Mailer 7.4 or newer within the 7.x series
composer require josbeir/cakephp-symfony-mailer
bin/cake plugin load CakeSymfonyMailerInstall the Symfony provider bridge and any additional component required by the chosen DSN. The Mailgun bridge depends on symfony/mailer, but its HTTP API transport does not pull in symfony/http-client automatically. For Mailgun API delivery, install both explicitly:
composer require symfony/mailgun-mailer symfony/http-clientConfigure the transport through CakePHP's normal EmailTransport settings:
use CakeSymfonyMailer\Mailer\Transport\SymfonyMailerTransport;
'EmailTransport' => [
'default' => [
'className' => SymfonyMailerTransport::class,
'dsn' => env('MAILER_DSN'),
],
],Examples of Symfony DSNs include:
# Mailgun API (install symfony/mailgun-mailer and symfony/http-client)
MAILER_DSN='mailgun+https://API_KEY:DOMAIN@default'
# SMTP
MAILER_DSN='smtp://user:password@smtp.example.com:587?require_tls=true'
# Symfony failover transport
MAILER_DSN='failover(smtp://user:password@smtp.example.com:587 smtp://user:password@smtp-backup.example.com:587)'Follow Symfony Mailer's DSN escaping rules for credentials containing reserved URI characters.
composer install
composer test
composer cs-check
composer stan
composer rector-checkThe checks run PHPUnit, PHPCS, PHPStan at level 10, and Rector in dry-run mode. Coverage is collected separately with:
composer test-coverageThe CI coverage job requires a coverage driver and publishes a Clover report for src/.
MIT. See LICENSE.