A Laravel package to interact with the Listmonk API, providing a fluent interface to manage subscribers, lists, campaigns, and more.
- 🚀 Full API coverage for Listmonk
- 🔄 Fluent, object-oriented API
- 🛠 Built with Laravel best practices
- 📦 Easy installation and configuration
- 🔍 Comprehensive test suite
- 📝 Well-documented methods
- PHP 8.0 or higher
- Laravel 9.x or higher
- Listmonk 2.0 or higher
You can install the package via Composer:
composer require knackline/laravel-listmonkPublish the config file with:
php artisan vendor:publish --provider="Knackline\Listmonk\Providers\ListmonkServiceProvider" --tag="listmonk-config"Update your .env file with your Listmonk credentials:
LISTMONK_URL=https://your-listmonk-installation.com
LISTMONK_USERNAME=your-username
LISTMONK_PASSWORD=your-passwordOr modify the config/listmonk.php file directly.
use Knackline\Listmonk\Facades\Listmonk;
// Get all subscribers
$subscribers = Listmonk::getSubscribers();
// Create a new subscriber
$subscriber = Listmonk::createSubscriber([
'email' => 'user@example.com',
'name' => 'John Doe',
'status' => 'enabled',
'lists' => [1, 2], // List IDs to subscribe to
]);use Knackline\Listmonk\ListmonkClient;
class YourController
{
protected $listmonk;
public function __construct(ListmonkClient $listmonk)
{
$this->listmonk = $listmonk;
}
public function index()
{
$subscribers = $this->listmonk->getSubscribers();
// ...
}
}getSubscribers(array $filters = [])- Get all subscribersgetSubscriber(int $id)- Get a subscriber by IDcreateSubscriber(array $data)- Create a new subscriberupdateSubscriber(int $id, array $data)- Update a subscriberdeleteSubscriber(int $id)- Delete a subscriberblocklistSubscriber(int $id)- Blocklist a subscriber
getLists(array $filters = [])- Get all listsgetList(int $id)- Get a list by IDcreateList(array $data)- Create a new listupdateList(int $id, array $data)- Update a listdeleteList(int $id)- Delete a list
getCampaigns(array $filters = [])- Get all campaignsgetCampaign(int $id)- Get a campaign by IDcreateCampaign(array $data)- Create a new campaignupdateCampaign(int $id, array $data)- Update a campaigndeleteCampaign(int $id)- Delete a campaignsendCampaign(int $campaignId, bool $sendNow = false)- Send a campaign
getTemplates()- Get all templatesgetTemplate(int $id)- Get a template by IDcreateTemplate(array $data)- Create a new templateupdateTemplate(int $id, array $data)- Update a templatedeleteTemplate(int $id)- Delete a template
sendTransactionalEmail(string $to, string $subject, string $body, array $data = [])- Send a transactional email
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.