spatie/laravel-mailcoach-postmark-setup
Prepares a Postmark account for use with Mailcoach by configuring inbound processing for campaign feedback (bounces, complaints, events). Intended for internal use by Mailcoach; code is usable standalone but comes with no docs or support.
Installation
composer require spatie/laravel-mailcoach-postmark-setup
Publish the config file:
php artisan vendor:publish --provider="Spatie\MailcoachPostmarkSetup\MailcoachPostmarkSetupServiceProvider"
Configuration
Edit config/mailcoach-postmark-setup.php with your Postmark API token and server token.
First Use Case Run the setup command to configure Postmark for Mailcoach:
php artisan mailcoach:postmark:setup
This creates a Postmark server token, sets up webhooks, and configures tracking domains.
Pre-Campaign Setup
mailcoach:postmark:setup command before launching campaigns to ensure Postmark is configured for tracking and feedback loops.Webhook Handling
Dynamic Configuration
PostmarkSetup class to customize behavior (e.g., additional webhook endpoints or server token permissions):
use Spatie\MailcoachPostmarkSetup\PostmarkSetup;
class CustomPostmarkSetup extends PostmarkSetup {
protected function configureServerToken(): void {
$this->serverToken->permissions = ['inbound', 'outbound', 'message_stream'];
}
}
Testing
'sandbox' => env('MAILCOACH_POSTMARK_SANDBOX', false),
API Token Permissions
server_tokens:read_write permissions. Missing this will fail during setup.Webhook Verification
config('mailcoach-postmark-setup.webhook_url') to verify the endpoint matches your app’s route.Tracking Domains
Rate Limits
config/mailcoach-postmark-setup.php to log API responses:
'debug' => env('MAILCOACH_POSTMARK_DEBUG', false),
Custom Webhooks
Override handleWebhook() in a custom service provider to process Postmark events differently:
public function boot(): void {
$this->app->make(\Spatie\MailcoachPostmarkSetup\PostmarkSetup::class)
->setWebhookHandler(function ($event) {
// Custom logic
});
}
Postmark Client Access the underlying Postmark client for advanced use:
$postmark = app(\Spatie\MailcoachPostmarkSetup\PostmarkSetup::class)->getPostmarkClient();
Environment-Specific Config
Use Laravel’s config() helper to dynamically set options per environment:
'server_token_permissions' => config('app.env') === 'production' ? ['inbound'] : [],
How can I help you explore Laravel packages today?