- How do I install and set up spatie/laravel-newsletter for MailerLite?
- Run `composer require spatie/laravel-newsletter`, then publish the config with `php artisan vendor:publish --tag=newsletter-config`. Configure your MailerLite API key and default group ID in `config/newsletter.php` under the `mailerlite` section. No migrations are needed—just start subscribing users via `Newsletter::subscribe()`.
- Can I use this package with Laravel 10+? What versions are supported?
- Yes, the package is fully compatible with Laravel 10 and 11. It also supports Laravel 9 and 8. Check the [GitHub releases](https://github.com/spatie/laravel-newsletter/releases) for version-specific requirements. Always test in a staging environment before upgrading.
- How do I switch from Mailchimp to MailerLite without breaking my app?
- Update the `default` driver in `config/newsletter.php` to `mailerlite`. The package’s unified API ensures no changes to your subscription logic are needed. Run `Newsletter::syncLists()` to migrate existing subscribers if required, or use the provider’s native tools for bulk migration.
- Does this package support webhooks for MailerLite? How do I set them up?
- Yes, MailerLite webhooks (e.g., `subscriber:created`) can be mapped to Laravel events. Use the `Webhook` class to validate signatures and dispatch events like `NewsletterSubscribed`. Configure the webhook URL in `config/newsletter.php` under `mailerlite.webhook_url`.
- How do I handle custom fields (tags, attributes) for MailerLite subscribers?
- MailerLite supports custom fields via the `merge_fields` or `custom_fields` parameters in the `subscribe()` method. Pass an array like `['custom_fields' => ['field1' => 'value1']]` to the method. Test field mappings early, as MailerLite’s API may differ from Mailchimp’s.
- What’s the best way to test newsletter subscriptions in Laravel?
- Use Laravel’s mocking to test interactions with the Newsletter facade. Example: `$this->mock(Newsletter::class)->shouldReceive('subscribe')->once()`. For MailerLite-specific tests, mock the `MailerLite` service directly. Integration tests should verify webhook signatures and API responses.
- Will this package work with Laravel queues for async newsletter operations?
- Yes, all subscription/unsubscription operations are queueable by default. Use `Newsletter::subscribe($email)->onQueue('newsletters')` to offload work. For heavy loads, optimize batching or retry logic in the `MailerLite` driver’s API calls.
- How do I handle rate limits or API errors from MailerLite?
- The package automatically retries failed API calls with exponential backoff. For rate limits, configure `mailerlite.api_timeout` in the config or implement custom retry logic in a service provider. Monitor MailerLite’s [status page](https://mailerlite.com/status) for outages.
- Can I use this package for both marketing and transactional emails?
- Yes, but evaluate MailerLite’s feature parity for transactional use cases (e.g., automation, segmentation). The package supports multi-provider setups—route subscribers to MailerLite for marketing and another provider for transactions by checking the `default` driver in your config.
- Are there alternatives to this package for Laravel newsletter management?
- Alternatives include `spatie/laravel-mailcoach` (for Mailcoach-only apps), `spatie/laravel-activitylog` (for tracking subscriptions), or provider-specific SDKs like `mailerlite/mailerlite`. This package stands out for its unified API, multi-provider support, and Laravel-native integration.