- How do I integrate Mailgun feedback loops with Laravel Mailcoach?
- First, ensure Mailcoach is installed and Mailgun is your email driver in `.env`. Then install this package via Composer, publish its config, and set up Mailgun webhooks pointing to `/mailcoach/mailgun-feedback` for bounced, unsubscribed, and complained events. The package handles the rest by updating recipient statuses in Mailcoach.
- What Laravel versions does this package support?
- This package is compatible with Laravel 8, 9, and 10, requiring PHP 8.0 or higher. Ensure your Mailcoach installation matches these constraints, as it’s a core dependency.
- Can I customize how feedback is processed (e.g., trigger Slack alerts)?
- Yes, the package uses Laravel’s observer pattern via `FeedbackLoopObserver`, allowing you to extend or override default behavior. For example, you can listen for feedback events and dispatch custom logic like Slack notifications or CRM updates.
- What happens if Mailgun retries a webhook during Laravel downtime?
- The package includes idempotency checks by default, deduplicating events using the Mailgun event ID and recipient identifier. However, ensure your Laravel app can handle retries gracefully, ideally by queuing feedback processing to avoid race conditions.
- Do I need to configure additional database tables for feedback processing?
- No, this package relies entirely on Mailcoach’s existing `recipients` table to update statuses (e.g., marking users as bounced or unsubscribed). No additional database migrations or schema changes are required.
- How do I verify Mailgun webhook signatures to prevent spoofing?
- The package automatically validates Mailgun’s `X-Mailgun-Signature` header using Laravel’s built-in middleware. Ensure your webhook endpoint includes `VerifyCsrfToken` middleware and that your Mailgun API key is securely stored in `.env` (e.g., `MAILGUN_SECRET`).
- What’s the recommended approach for high-volume feedback loops (e.g., 10K/day)?
- For high-volume scenarios, queue feedback processing by dispatching a job (e.g., `mailcoach:process-feedback`) via Laravel’s queue system. Use Redis or database queues to decouple webhook handling from immediate execution, improving performance and reliability.
- Can I handle custom feedback types like ‘complaints’ beyond Mailgun’s defaults?
- Yes, the package supports custom feedback types. Extend the `FeedbackLoopObserver` to map additional Mailgun events (e.g., complaints) to Mailcoach’s statuses or trigger custom logic. Check the `config/mailcoach-mailgun-feedback.php` for event mappings.
- How do I monitor or log processed feedback for auditing?
- Laravel’s default logging system captures feedback processing. For advanced monitoring, integrate with tools like Sentry, Laravel Horizon, or Datadog to track webhook failures, processing times, or errors. Logs are stored in `storage/logs/laravel.log` by default.
- What alternatives exist if I’m not using Mailcoach or Mailgun?
- If you’re not using Mailcoach, consider alternatives like Laravel’s built-in mail queues with custom feedback handlers for Mailgun or other providers (e.g., SendGrid, Postmark). For Mailcoach, this package is the official Mailgun integration, but you could build a similar solution using Laravel’s `Mailgun` facade and event listeners.