spatie/laravel-mailcoach-ses-setup
Prepares and configures Amazon SES accounts for use with Mailcoach, enabling proper setup for email campaign sending and feedback handling (bounces/complaints). Intended for internal Mailcoach use; minimal documentation or support provided.
Installation
composer require spatie/laravel-mailcoach-ses-setup
Publish the config file:
php artisan vendor:publish --provider="Spatie\MailcoachSesSetup\MailcoachSesSetupServiceProvider"
Configuration
Edit .env with your AWS SES credentials:
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_DEFAULT_REGION=your-region (e.g., us-east-1)
First Use Case Run the SES setup command to verify and configure SES for Mailcoach:
php artisan mailcoach:ses:setup
This will:
config/mailcoach-ses-setup.php – Contains AWS SES settings, verification rules, and logging preferences.php artisan to explore available commands (mailcoach:ses:setup, mailcoach:ses:verify).Pre-Campaign Setup
mailcoach:ses:setup to configure SES before sending campaigns.mailcoach:ses:verify:email or mailcoach:ses:verify:domain.Daily Operations
Spatie\MailcoachSesSetup\ProcessFeedback).
Example:
use Spatie\MailcoachSesSetup\ProcessFeedback;
$feedback = new ProcessFeedback();
$feedback->process($rawNotification); // Parse SES feedback (bounce/complaint)
Automation
php artisan schedule:run
Add to app/Console/Kernel.php:
$schedule->command('mailcoach:ses:verify')->daily();
Testing
AWS_SDK_DATA environment variable to mock SES responses in tests:
AWS_SDK_DATA=tests/AwsData
config/mail.php uses SES as the driver:
'driver' => env('MAIL_DRIVER', 'ses'),
Mailcoach\Events\CampaignSent to trigger SES-specific actions:
use Mailcoach\Events\CampaignSent;
CampaignSent::listen(function ($campaign) {
// Log SES metrics or trigger verification if needed
});
config/mailcoach-ses-setup.php to trace SES interactions:
'log' => [
'enabled' => true,
'channel' => 'single',
],
AWS Credentials
.env can leak. Use IAM roles or AWS Secrets Manager in production.AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY and restrict IAM permissions to SES-only actions.SES Verification Delays
Sandbox Restrictions
mailcoach:ses:setup.Feedback Processing
AWS_KMS_KEY_ID is set in .env if using encrypted notifications.storage/logs/laravel.log) for AWS SDK errors (e.g., InvalidAccessKeyId).use Aws\Common\Exception\RetryException;
try {
$ses->verifyEmailAddress(['EmailAddress' => 'test@example.com']);
} catch (RetryException $e) {
// Handle retry logic
}
dd($rawNotification) to inspect raw data.Custom Verification Logic
Override the verification process by extending Spatie\MailcoachSesSetup\Commands\SetupSesCommand:
namespace App\Console\Commands;
use Spatie\MailcoachSesSetup\Commands\SetupSesCommand as BaseCommand;
class CustomSetupSesCommand extends BaseCommand {
protected function verifySesIdentity() {
// Custom logic (e.g., skip verification for staging)
}
}
Feedback Handlers
Extend Spatie\MailcoachSesSetup\ProcessFeedback to add custom actions (e.g., auto-suppress bounces):
namespace App\Services;
use Spatie\MailcoachSesSetup\ProcessFeedback as BaseFeedback;
class CustomFeedback extends BaseFeedback {
protected function handleBounce($feedback) {
// Custom bounce handling (e.g., update user record)
}
}
SES Metrics Integrate with Laravel Horizon or Telescope to track SES metrics:
use Spatie\MailcoachSesSetup\Facades\MailcoachSesSetup;
$metrics = MailcoachSesSetup::getSesMetrics();
// Log or broadcast metrics
AWS_DEFAULT_REGION matches the SES region (e.g., us-east-1 for Virginia).log.channel in config defaults to single. Use stack for multi-environment logging:
'log' => [
'channel' => env('MAILCOACH_SES_LOG_CHANNEL', 'stack'),
],
MAILCOACH_SES_* prefixes for custom configs. Override via .env:
MAILCOACH_SES_VERIFY_DOMAINS=example.com,test.org
How can I help you explore Laravel packages today?