hocza/sendy is a Laravel package for sendy api implementation for laravel.
It currently has 71 GitHub stars and 211.527 downloads on Packagist (latest version 1.1.1).
Install it with composer require hocza/sendy.
Discover more Laravel packages by hocza
or browse all Laravel packages to compare alternatives.
Last updated

A service provider for Sendy API in Laravel 5
composer require hocza/sendy:1.*
or append your composer.json with:
{
"require" : {
"hocza/sendy": "1.*"
}
}
Add the following settings to the config/app.php
Service provider:
'providers' => [
// ...
'Hocza\Sendy\SendyServiceProvider',
]
For the Sendy:: facade
'aliases' => [
// ...
'Sendy' => 'Hocza\Sendy\Facades\Sendy',
]
php artisan vendor:publish --provider="Hocza\Sendy\SendyServiceProvider"
It will create sendy.php within the config directory.
<?php
return [
'listId' => '',
'installationUrl' => '',
'apiKey' => '',
];
$data = [
'email' => '[email protected]',
'name' => 'John Doe',
'any_custom_column' => 'value',
];
Sendy::subscribe($data);
RESPONSE (array)
In case of success:
['status' => true, 'message' => 'Subscribed']
['status' => true, 'message' => 'Already subscribed']
In case of error:
['status' => false, 'message' => 'The error message']
$email = '[email protected]';
Sendy::unsubscribe($email);
RESPONSE (array)
In case of success:
['status' => true, 'message' => 'Unsubscribed']
In case of error:
['status' => false, 'message' => 'The error message']
$email = '[email protected]';
Sendy::status($email);
RESPONSE (Plain text)
Success:
SubscribedUnsubscribedUnconfirmedBouncedSoft bouncedComplainedError:
No data passedAPI key not passedInvalid API keyEmail not passedList ID not passedEmail does not exist in listSendy::count();
#To check other list:
Sendy::setListId($list_id)->count();
RESPONSE (Plain text)
Success:
You'll get an integer of the active subscriber countError:
No data passedAPI key not passedInvalid API keyList ID not passedList does not exist<?php
$campaignOptions = [
'from_name' => 'My Name',
'from_email' => '[email protected]',
'reply_to' => '[email protected]',
'title' => 'My Campaign',
'subject' => 'My Subject',
'list_ids' => '1,2,3', // comma-separated, optional
'brand_id' => 1,
'query_string' => 'utm_source=sendy&utm_medium=email&utm_content=email%20newsletter&utm_campaign=email%20newsletter',
];
$campaignContent = [
'plain_text' => 'My Campaign',
'html_text' => View::make('mail.my-campaign'),
];
$send = false;
Sendy::createCampaign($campaignOptions, $campaignContent, $send);
RESPONSE (Plain text)
Success:
Campaign createdCampaign created and now sendingError:
No data passedAPI key not passedInvalid API keyFrom name not passedFrom email not passedReply to email not passedSubject not passedHTML not passedList ID(s) not passedOne or more list IDs are invalidList IDs does not belong to a single brandBrand ID not passedUnable to create campaignUnable to create and send campaignTo change the default list ID simply prepend with setListId($list_id)
Examples:
Sendy::setListId($list_id)->subscribe($data);
Sendy::setListId($list_id)->unsubscribe($email);
Sendy::setListId($list_id)->status($email);
Sendy::setListId($list_id)->count();