coderflexx / laravel-sendy
Laravel Sendy is a simple and clean wrapper for the Sendy API, making it easy to manage subscribers, lists, and campaigns directly from your Laravel application.
Fund package maintenance!
Coderflex
Requires
- php: ^8.3
- ext-curl: *
- ext-json: *
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-data: ^4.15
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
This package is auto-updated.
Last update: 2025-05-05 10:41:29 UTC
README
Laravel Sendy is a simple and clean wrapper for the Sendy API, making it easy to manage subscribers, lists, and campaigns directly from your Laravel application.
Installation
You can install the package via composer:
composer require coderflexx/laravel-sendy
You can publish the config file with:
php artisan vendor:publish --tag="laravel-sendy"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Sendy Installation URL |-------------------------------------------------------------------------- | | This URL is used to connect to your Sendy installation. It should | point to the root of your Sendy installation. For example: | https://your-sendy-installation.com */ 'sendy_installation_url' => env('SENDY_INSTALLATION_URL', 'https://your-sendy-installation.com'), /* |-------------------------------------------------------------------------- | Sendy API Key |-------------------------------------------------------------------------- | | This key is used to authenticate your application with the Sendy | installation. You can find your API key in the Sendy settings. | Make sure to keep this key secure and do not share it with anyone. | It is recommended to use environment variables to store sensitive | information like API keys. You can set the SENDY_API_KEY */ 'sendy_api_key' => env('SENDY_API_KEY', 'your-sendy-api-key'), ];
API Keys
After Installation, you can grab your API KEYS
from the sendy app installation, then add them in .env
file
SENDY_INSTALLATION_URL=https://your-app-installation.com/ SENDY_API_KEY=your-api-key
Sendy Version
This package is compatible with Sendy v6.1.2 (Latest)
Usage
In order to use the package, you can use the facade directly, followed by the main method api (e.g. subscribers()
then the verb (action))
use Coderflex\LaravelSendy\Facades\Sendy; $sendy = Sendy::{$service()}->{$action()}
Async Argument for HTTP Requests
All HTTP requests support an async
option, allowing you to defer execution. This is useful when a request doesn't need to run immediately or isn't a high priority. You can handle it later using await when you're ready to process the result.
Example:
$promise = Sendy::subscribers()->subscribe( data: $data, async: true // The request is deferred and returns a promise ); // perform other tasks/operation here // later, wait for the response when you're ready. $response = $promise->await();
Subscribers
In order to create a create/delete a subscriber, you have to access the subscribers service first, then to the action
Subscribe a User
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'name' => 'John Doe', 'email' => 'john@example.com', 'list' => '123', 'country' => 'US', ]; $response = Sendy::subscribers()->subscribe( data: $data, async: false );
Full Documentation Here
Unsubscribe a User
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'email' => 'john@example.com', 'list' => '123', 'boolean' => true, // to get plan text response, instead of json. ]; $response = Sendy::subscribers()->unsubscribe( data: $data, async: false );
Full Documentation Here
Delete Subscriber
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'email' => 'john@example.com', 'list_id' => '123', ]; $response = Sendy::subscribers()->delete( data: $data, async: false );
Full Documentation Here
Subscriber Status
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'email' => 'john@example.com', 'list_id' => '123', ]; $response = Sendy::subscribers()->status( data: $data, async: false );
Full Documentation Here
Subscribers Count
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'email' => 'john@example.com', 'list_id' => '123', ]; $response = Sendy::subscribers()->count( listId: '123', async: false );
Full Documentation Here
Lists
Same thing as the subscribers service, you can access the lists()
service, then the http action you want.
Get Lists
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'brand_id' => '123', 'include_hidden' => 'yes', // either yes or no. ]; $response = Sendy::lists()->get( data: $data, async: false );
Full Documentation Here
Brands
Laravel Sendy allows you to retrieve all the brand list you have by
use Coderflex\LaravelSendy\Facades\Sendy; $response = Sendy::brands()->get();
Full Documentation Here
Create & Send Compaigns
use Coderflex\LaravelSendy\Facades\Sendy; $data = [ 'subject' => 'Test Subject', 'from_name' => 'John Doe', 'from_email' => 'john@example.com', 'reply_to' => 'alex@example.com', 'title' => 'Test Title', 'plain_text' => 'This is a plain text version of the email.', 'html_text' => '<h1>This is a HTML version of the email.</h1>', 'list_ids' => 'abc123', 'segment_ids' => 'xyz456', 'exclude_list_ids' => null, 'exclude_segment_ids' => null, 'brand_id' => '123', 'query_string' => null, 'track_opens' => 1, 'track_clicks' => 1, 'send_campaign' => 1, // if set to 1 the compaign will be created & sent. 'schedule_date_time' => null, 'schedule_timezone' => null, ]; $response = Sendy::compaigns()->create( data: $data, async: false );
If you want to create and send the compaign at the same time, use createAndSend
method
$response = Sendy::compaigns()->createAndSend( data: $data, async: false );
Full Documentation Here
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.