spatie/mailcoach-mailer
Symfony Mailer transport for sending transactional email via Mailcoach. Install with composer, then configure Mailcoach credentials to deliver messages through Mailcoach’s transactional mail feature. Laravel users: see spatie/laravel-mailcoach-mailer.
laravel-mailcoach-mailer), which abstracts Symfony Mailer under the hood.spatie/laravel-mailcoach-mailer) simplifies integration by leveraging Laravel’s native Mail facade, reducing Symfony dependency overhead.config/mail.php.mail.sent, mail.failed) for tracking, but requires additional setup for real-time processing.SwiftMailer → Symfony Mailer).spatie/laravel-mailcoach-mailer over the Symfony version to avoid introducing Symfony Mailer as a dependency.composer.json for exact versions).Mail facade, notifications, and queue systems.Installation:
composer require spatie/laravel-mailcoach-mailer
Configuration:
php artisan vendor:publish --provider="Spatie\MailcoachMailer\MailcoachMailerServiceProvider"
config/mail.php to use the mailcoach transport:
'default' => env('MAIL_MAILER', 'mailcoach'),
'mailers' => [
'mailcoach' => [
'transport' => 'mailcoach',
],
],
'mailcoach' => [
'api_key' => env('MAILCOACH_API_KEY'),
'endpoint' => env('MAILCOACH_ENDPOINT', 'https://mailcoach.app/api'),
],
Usage:
Mail::to($user)->send(new OrderShipped()) with the same code—no facade changes needed.Webhooks (Optional):
/api/mailcoach/webhook).Http\Middleware\VerifyCsrfToken exception or a secret token for security.public_path() resolves correctly).mailcoach transport is queueable:
Mail::later(now()->addMinutes(5), 'mailcoach', new OrderShipped(), $user);
MailcoachMailerFake for unit tests:
use Spatie\MailcoachMailer\Testing\MailcoachMailerFake;
beforeEach(function () {
MailcoachMailerFake::fake();
});
telescope or laravel-log.MAIL_MAILER in .env to mailcoach.MailcoachHttpClient exceptions).spatie/laravel-mailcoach-mailer for breaking changes (MIT license allows for updates).MAILCOACH_API_KEY and endpoint.config/mailcoach.php:
'debug' => env('MAILCOACH_DEBUG', false),
queue:work) will scale horizontally, but Mailcoach API calls must be idempotent (retrying the same email shouldn’t cause duplicates).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Mailcoach API downtime | Transactional emails fail silently. | Fallback to a secondary SMTP (e.g., AWS SES) via queue retry logic. |
| Rate limit exceeded | Emails queue up or fail. | Implement retry logic with jitter and monitor queue backlog. |
| Webhook delivery failures | Missing event data (e.g., opens). | Store webhook payloads in a DB and reprocess failed events. |
| API key rev |
How can I help you explore Laravel packages today?