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 the Laravel Mailcoach SDK in my project?
Run `composer require spatie/laravel-mailcoach-sdk` in your Laravel project. The package supports Laravel 12+ and will automatically register its service provider. Configure your Mailcoach API token in your `.env` file under `MAILCOACH_API_TOKEN`.
Does this SDK work with Mailcoach Cloud or only self-hosted?
The SDK supports both Mailcoach Cloud and self-hosted instances (version 6 and above). You only need to configure the correct API endpoint in your `.env` file, and the SDK will handle the rest. No additional setup is required.
Can I use this SDK to send bulk emails or campaigns to large lists?
The SDK supports sending campaigns, but all operations are synchronous by default. For large lists (e.g., 100K+ subscribers), consider using Laravel queues to process sends asynchronously. The SDK itself doesn’t include async support, so you’ll need to implement it manually.
How do I handle paginated API responses, like fetching all subscribers?
The SDK simplifies pagination with a `next()` method. For example, fetch subscribers in a loop: `$subscribers = $mailcoach->emailList('uuid')->subscribers(); do { foreach($subscribers as $subscriber) { ... } } while($subscribers = $subscribers->next())`. This works seamlessly for large datasets.
Is there a way to test my Laravel app’s Mailcoach interactions without hitting the real API?
Yes! Use `Mailcoach::fake()` in your tests to mock API responses. This is especially useful for unit testing campaigns, subscribers, or lists. The fake method simulates API calls, so you can verify logic without external dependencies.
What Laravel versions does this SDK support, and will it work with older projects?
The SDK requires Laravel 12+ (as of v1.5.0). If your project uses an older version, you’ll need to either upgrade Laravel or fork the package to support your version. Check the [GitHub releases](https://github.com/spatie/laravel-mailcoach-sdk/releases) for version-specific details.
How do I secure the Mailcoach API token in production?
Store the `MAILCOACH_API_TOKEN` in your `.env` file, which Laravel automatically loads. For enhanced security, consider using a secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault) or Laravel’s `env()` helper to dynamically fetch tokens at runtime.
Are there any alternatives if I need multi-provider email marketing support?
This SDK is Mailcoach-specific, so if you need multi-provider support (e.g., Mailgun, SendGrid), consider generic HTTP clients like Guzzle with a wrapper layer or packages like `spatie/laravel-newsletter`. However, those won’t offer Mailcoach’s native features like campaign management.
How do I handle errors or failed API requests from Mailcoach?
The SDK includes basic error handling for issues like missing credentials or invalid responses. For custom Mailcoach API errors, check the response object or implement middleware to log/handle exceptions. Laravel’s `try-catch` blocks can wrap SDK calls for graceful error recovery.
Can I extend or customize the SDK for my specific needs?
Yes! The SDK is designed to work with Laravel’s service container, so you can bind custom implementations or extend models (e.g., `EmailList`, `Campaign`) via service providers. Override methods like `send()` or add middleware to modify behavior before API calls.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony