Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Mailcoach Sdk

Laravel Mailcoach Sdk Laravel Package

spatie/laravel-mailcoach-sdk

Laravel SDK for the Mailcoach API (self-hosted v6+ and Mailcoach Cloud). Manage email lists, subscribers and campaigns, create and send campaigns, send test emails, and easily iterate paginated API resources with next().

View on GitHub
Deep Wiki
Context7

An SDK to easily work with the Mailcoach API in Laravel apps

Frequently asked questions about Laravel Mailcoach Sdk
How do I install spatie/laravel-mailcoach-sdk in my Laravel project?
Run `composer require spatie/laravel-mailcoach-sdk` in your project directory. The package will automatically register itself with Laravel’s service container. No additional configuration is needed unless you’re using custom API endpoints or need to publish the config file.
Does this SDK support both self-hosted Mailcoach and Mailcoach Cloud?
Yes, the SDK works with both self-hosted Mailcoach (version 6 and above) and Mailcoach Cloud. You only need to configure the correct API endpoint in your `.env` file using the `MAILCOACH_API_URL` key.
Can I create and send campaigns programmatically with this package?
Absolutely. Use `Mailcoach::createCampaign()` to define a campaign with fields like title and content, then call `$campaign->send()` to launch it. You can also send test emails with `$campaign->sendTest('email@example.com')` before full deployment.
How does pagination work with large subscriber lists or campaigns?
The SDK handles pagination automatically. After fetching a collection (e.g., subscribers), call `$collection->next()` to iterate through subsequent pages. Each page defaults to 1000 items, but you can adjust this via the API configuration if needed.
Is there a way to test my Laravel app’s Mailcoach interactions without hitting a real API?
Yes, the SDK includes a `fake()` method for testing. Call `Mailcoach::fake()` in your tests to mock API responses. This is useful for unit and integration tests, though complex workflows (like scheduled campaigns) may require custom test doubles.
What Laravel versions does spatie/laravel-mailcoach-sdk support?
The package officially supports Laravel 12 and above. If you’re using an older version (e.g., Laravel 10 or 11), you may need to check the package’s release notes or fork it for compatibility, as it drops support for versions below Laravel 12.
How do I handle API errors or rate limits when using this SDK?
The SDK provides basic error handling for missing credentials or invalid requests. However, Mailcoach’s API may impose rate limits, which aren’t automatically retried. Implement retries or exponential backoff at the application level using Laravel’s HTTP client or Guzzle.
Can I use this SDK to sync Mailcoach data with my Laravel database?
The SDK doesn’t include built-in syncing, but you can manually fetch data (e.g., subscribers) and store it in your Laravel database. For example, loop through paginated results with `->next()` and save them to a local table. Consider caching frequently accessed data.
Are there alternatives to this SDK if I need more advanced email marketing features?
If Mailcoach’s feature set is limiting (e.g., lack of webhooks or advanced analytics), consider alternatives like Laravel’s native Mail API for simple emails, or third-party SDKs for services like Mailgun, SendGrid, or Postmark. However, this SDK is ideal for deep Mailcoach integration.
How do I secure my Mailcoach API token in production?
Store your `MAILCOACH_API_TOKEN` in Laravel’s `.env` file, which is excluded from version control. For additional security, use Laravel’s environment-based configuration or a secrets manager like AWS Secrets Manager or HashiCorp Vault, especially in shared hosting environments.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai