spatie/laravel-mailcoach-sendinblue-feedback
Addon for spatie/laravel-mailcoach that processes Sendinblue campaign feedback (bounces, complaints, etc.) so Mailcoach can automatically handle delivery events and keep subscriber status and stats in sync.
Installation
composer require spatie/laravel-mailcoach-sendinblue-feedback
Publish the config file:
php artisan vendor:publish --provider="Spatie\MailcoachSendinblueFeedback\MailcoachSendinblueFeedbackServiceProvider"
Configuration
Ensure your .env has Sendinblue API credentials:
SENDINBLUE_API_KEY=your_api_key_here
MAILCOACH_SENDINBLUE_FEEDBACK_ENABLED=true
First Use Case After sending a campaign via Mailcoach, the package automatically processes feedback (bounces, spam reports, unsubscribe events) from Sendinblue. No manual intervention is required—just ensure your Mailcoach campaigns are configured to use Sendinblue as the mail provider.
Automatic Feedback Processing The package hooks into Mailcoach’s campaign lifecycle. When a campaign is sent via Sendinblue, the package:
Manual Triggering (Advanced Use) If needed, manually trigger feedback processing for a specific campaign:
use Spatie\MailcoachSendinblueFeedback\Facades\SendinblueFeedback;
SendinblueFeedback::processFeedbackForCampaign($campaignId);
Event Listeners Extend functionality by listening to feedback events. Example:
// In EventServiceProvider
protected $listen = [
'Spatie\MailcoachSendinblueFeedback\Events\FeedbackProcessed' => [
'App\Listeners\LogFeedbackToDatabase',
],
];
Custom Feedback Handling Override default behavior by binding your own handler:
// In a service provider
$this->app->bind(
Spatie\MailcoachSendinblueFeedback\FeedbackHandlers\FeedbackHandler::class,
App\Handlers\CustomSendinblueFeedbackHandler::class
);
API Rate Limits Sendinblue’s API has rate limits. If processing large campaigns, implement retries with exponential backoff:
// config/mailcoach-sendinblue-feedback.php
'max_retries' => 3,
'retry_delay_seconds' => 10,
Timezone Mismatches
Ensure Sendinblue’s timestamps align with your Laravel app’s timezone (configured in config/app.php). Feedback events may appear misaligned otherwise.
Webhook vs. Polling The package uses polling (not webhooks) by default. For real-time processing, consider:
Recipient Matching Feedback events rely on email addresses to match recipients. Ensure:
user@example.com vs. User@example.com).Enable Debug Logging
Add to .env:
MAILCOACH_SENDINBLUE_FEEDBACK_LOG_LEVEL=debug
Check logs at storage/logs/laravel.log.
Verify API Credentials Test connectivity with:
php artisan mailcoach:sendinblue-feedback:test-connection
Check Feedback Events Inspect processed events in the database table:
SELECT * FROM mailcoach_feedback_events;
Custom Feedback Types
Extend the FeedbackHandler to process additional Sendinblue event types (e.g., soft bounces):
namespace App\Handlers;
use Spatie\MailcoachSendinblueFeedback\FeedbackHandlers\FeedbackHandler;
class CustomSendinblueFeedbackHandler extends FeedbackHandler
{
protected function handleSoftBounce($event)
{
// Custom logic
}
}
Database Schema
Modify the mailcoach_feedback_events table by publishing and extending the migration:
php artisan vendor:publish --tag="mailcoach-sendinblue-feedback-migrations"
Testing Use the package’s test helpers to mock Sendinblue responses:
use Spatie\MailcoachSendinblueFeedback\Testing\MocksSendinblueFeedback;
public function testFeedbackProcessing()
{
$this->mockSendinblueFeedback();
// Assertions...
}
How can I help you explore Laravel packages today?