spatie/laravel-mailcoach-mailgun-feedback
Add-on for spatie/laravel-mailcoach that processes Mailgun feedback for your email campaigns. Capture events like bounces, complaints, and other Mailgun webhooks to keep Mailcoach lists and stats in sync.
spatie/laravel-mailcoach, designed to process Mailgun feedback loops (e.g., bounce, spam, and unsubscribe events). It fits seamlessly into an email marketing workflow where Mailgun is the transactional/transactional email provider.FeedbackLoopObserver), allowing customization of feedback processing logic (e.g., handling custom feedback types).spatie/laravel-mailcoach (v3.x+), which must already be integrated./mailcoach/mailgun-feedback).recipients table to update statuses.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Webhook Configuration | Misconfigured Mailgun webhooks may cause missed feedback or duplicate processing. | Validate webhook signatures (Mailgun provides X-Mailgun-Signature header). |
| Event Handling | Race conditions if Mailgun retries webhooks during Laravel downtime. | Implement idempotency (e.g., deduplicate by Mailgun-Event + recipient ID). |
| Mailcoach Version | Breaking changes if Mailcoach major version updates. | Pin spatie/laravel-mailcoach to a stable version in composer.json. |
| Performance | High-volume feedback loops could overload Laravel. | Queue feedback processing (e.g., mailcoach:process-feedback job). |
| Security | Webhook endpoint vulnerable to spoofing if not validated. | Use Laravel’s VerifyCsrfToken middleware + Mailgun’s signature verification. |
spatie/laravel-mailcoach if not already present..env:
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=your-domain
MAILGUN_SECRET=your-api-key
composer require spatie/laravel-mailcoach-mailgun-feedback
php artisan vendor:publish --provider="Spatie\MailcoachMailgunFeedback\MailcoachMailgunFeedbackServiceProvider"
config/mailcoach-mailgun-feedback.php (e.g., webhook endpoint, signature verification).https://your-app.test/mailcoach/mailgun-feedback
recipients table status field).VerifyMailgunWebhookSignature middleware for security.spatie/laravel-mailcoach-mailgun-feedback for updates (low-maintenance; Spatie provides changelogs).spatie/laravel-mailcoach cautiously (test feedback processing post-upgrade).Spatie\MailcoachMailgunFeedback\Events\FeedbackReceived events.X-Mailgun-Signature header (security failures).// In MailcoachMailgunFeedbackServiceProvider
$this->app->bind(
\Spatie\MailcoachMailgunFeedback\FeedbackLoopObserver::class,
function ($app) {
return new \Spatie\MailcoachMailgunFeedback\FeedbackLoopObserver(
$app->make(\Spatie\Mailcoach\Mailcoach::class),
new \Spatie\MailcoachMailgunFeedback\Jobs\ProcessFeedbackJob()
);
}
);
recipients table (e.g., use DB::transaction).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Mailgun Webhook Failures | Lost feedback events. | Mailgun retries webhooks (configure retry limits). Log failures for review. |
| Laravel Downtime | Missed feedback during outages. | Queue feedback processing; implement dead-letter queue for retries. |
| Database Locks | Slow feedback processing. | Use database transactions with lock-for-update for critical sections. |
| Mailcoach Version Conflict | Package breaks after upgrade. | Test in staging; roll back |
How can I help you explore Laravel packages today?