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.
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'),
];
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
This package is compatible with Sendy v6.1.2 (Latest)
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()}
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();
In order to create a create/delete a subscriber, you have to access the subscribers service first, then to the action
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'name' => 'John Doe',
'email' => '[email protected]',
'list' => '123',
'country' => 'US',
];
$response = Sendy::subscribers()->subscribe(
data: $data,
async: false
);
Full Documentation Here
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'email' => '[email protected]',
'list' => '123',
'boolean' => true, // to get plan text response, instead of json.
];
$response = Sendy::subscribers()->unsubscribe(
data: $data,
async: false
);
Full Documentation Here
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'email' => '[email protected]',
'list_id' => '123',
];
$response = Sendy::subscribers()->delete(
data: $data,
async: false
);
Full Documentation Here
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'email' => '[email protected]',
'list_id' => '123',
];
$response = Sendy::subscribers()->status(
data: $data,
async: false
);
Full Documentation Here
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'email' => '[email protected]',
'list_id' => '123',
];
$response = Sendy::subscribers()->count(
listId: '123',
async: false
);
Full Documentation Here
Same thing as the subscribers service, you can access the lists()
service, then the http action you want.
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
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
use Coderflex\LaravelSendy\Facades\Sendy;
$data = [
'subject' => 'Test Subject',
'from_name' => 'John Doe',
'from_email' => '[email protected]',
'reply_to' => '[email protected]',
'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
composer test
Please 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.