PHPackages                             jiririedl/php-sendy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jiririedl/php-sendy

ActiveLibrary[API Development](/categories/api)

jiririedl/php-sendy
===================

PHP class for using sendy API

4.0.3.3(6y ago)3066.1k↑185.1%8MITPHPPHP &gt;=5.3.0

Since Oct 29Pushed 6y ago7 watchersCompare

[ Source](https://github.com/jiririedl/php-sendy)[ Packagist](https://packagist.org/packages/jiririedl/php-sendy)[ Docs](https://github.com/jiririedl/php-sendy)[ RSS](/packages/jiririedl-php-sendy/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

PHP sendy client
================

[](#php-sendy-client)

PHP interface for Sendy api ([http://sendy.co/](http://sendy.co/?ref=q5mRD "Sendy - Send newsletters, 100x cheaper via Amazon SES")) with full support Sendy API ([http://sendy.co/api](http://sendy.co/api?ref=q5mRD "Sendy - API documentation"))

Installation
============

[](#installation)

Using composer
--------------

[](#using-composer)

Simply add new require `jiririedl/php-sendy` to your `composer.json`.

```
"require": {
    "jiririedl/php-sendy" : ">=1.0.0"
}
```

and update in console

```
composer update
```

Using autoload (alternative dirty way)
--------------------------------------

[](#using-autoload-alternative-dirty-way)

If you don't use Composer (for some reasons) you can download and include library bootstrap into your project manually. This wil add spl\_autoload for SendyPHP namespace.

```
$phpSendyPath = ''; // here you can fill something like 'vendor/SendyPHP'
require_once($phpSendyPath.'/bootstrap.php');
```

Using autoload method (alternative dirty dirty way)
---------------------------------------------------

[](#using-autoload-method-alternative-dirty-dirty-way)

If you have your own solution of class autoloading, there is prepared autload function in `/src/autoload.php`. Calling `\SendyPHP\autoload($className)` includes requested class from `SendyPHP` namespace or returns FALSE

Usage
=====

[](#usage)

Create instance of `\SendyPHP\Sendy` with URL of your Sendy installation and API key. Your API key is located in sendy - login as Admin and go to "Settings" (/settings) - your key is located in right side under topic "Your API key" beware of white spaces!

```
$sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');
```

Some request doesn't need API key for work (f.e. [subscribe()](#subscribe) or [unsubscribe()](#unsubscribe)) so setting api key is optional. You can also set api key by using [setApiKey()](#user-content-set-api-key) method or redefine sendy URL by [setURL()](#set-url).

Methods
-------

[](#methods)

### Sendy API Requests

[](#sendy-api-requests)

All requests uses curl library for calling Sendy API. If you have installed library by using Composer, curl was checked automatically, otherwise you can check this in your phpinfo, or just try to call some method from curl ().

#### Subscribe

[](#subscribe)

This method adds a new subscriber to a list. You can also use this method to update an existing subscriber.

```
bool subscribe($listID, $email, $name = NULL, array $customFields = array(), &$statusMessage = NULL)
```

##### Parameters

[](#parameters)

- $listID - the list id you want to subscribe a user to. This encrypted &amp; hashed id can be found under View all lists section named ID
- $email - user's email
- $name &lt;string|null&gt; - optional -user's name is optional
- $customFields - optional - associative array of custom fields and their values f.e. array('salutation'=&gt;'Mr.','userLevel'=&gt;'VIP+')
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example)

```
try{
    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $status = $sendy->subscribe('myHashedListID','newsubscribers@email.com','John Doe',$statusMessage);

    if($status)
        echo "Yeah! New subscriber successfully added";
    else
        echo "Ops! Sendy API responds a problem with adding subscriber - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\InvalidEmailException` is thrown if email address is not valid
- `\SendyPHP\Exception\DomainException` is thrown if $listID is empty
- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values)

Returns TRUE on success or FALSE on failure.

#### UnSubscribe

[](#unsubscribe)

This method unsubscribes a user from a list.

```
bool unsubscribe($listID, $email,&$statusMessage = NULL)
```

##### Parameters

[](#parameters-1)

- $listID - the list id you want to unsubscribe a user from. This encrypted &amp; hashed id can be found under View all lists section named ID
- $email - user's email
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example-1)

```
try{
    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $status = $sendy->unsubscribe('myHashedListID','newsubscribers@email.com',$statusMessage);

    if($status)
        echo "Subscriber successfully removed from list";
    else
        echo "Ops! Sendy API responds a problem with unsubscribing - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-1)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\InvalidEmailException` is thrown if email address is not valid
- `\SendyPHP\Exception\DomainException` is thrown if $listID is empty
- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values-1)

Returns TRUE on success or FALSE on failure.

#### Delete

[](#delete)

This method deletes a subscriber off a list (only supported in Sendy version 2.1.1.4 and above).

```
bool delete($listID, $email,&$statusMessage = NULL)
```

##### Parameters

[](#parameters-2)

- $listID - the list id you want to delete a user from. This encrypted &amp; hashed id can be found under View all lists section named ID
- $email - user's email
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example-2)

```
try{
    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $status = $sendy->delete('myHashedListID','newsubscribers@email.com',$statusMessage);

    if($status)
        echo "Subscriber successfully deleted from list";
    else
        echo "Ops! Sendy API responds a problem with deleting - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-2)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\InvalidEmailException` is thrown if email address is not valid
- `\SendyPHP\Exception\DomainException` is thrown if $listID is empty
- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values-2)

Returns TRUE on success or FALSE on failure.

#### Get active subscriber count

[](#get-active-subscriber-count)

This method gets the total active subscriber count.

```
number|false getActiveSubscriberCount($listID, &$statusMessage = NULL)
```

##### Parameters

[](#parameters-3)

- $listID - the list id you want to subscribe a user to. This encrypted &amp; hashed id can be found under View all lists section named ID
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example-3)

```
try{
    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $subscribersCount = $sendy->getActiveSubscriberCount('myHashedListID',$statusMessage);

    if($subscribersCount!==false)
        echo "In this list is $subscribersCount active subscribers";
    else
        echo "Ops! Sendy API responds a problem with getting active subscribers count - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-3)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\DomainException` is thrown if $listID is empty
- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values-3)

Returns number of active subscribers or FALSE on failure.

#### Get subscribtion status

[](#get-subscribtion-status)

This method gets the current status of a subscriber (eg. subscribed, unsubscribed, bounced, complained).

```
\SendyPHP\Response\SubscriptionStatus getSubscriptionStatus($listID, $email)
```

##### Parameters

[](#parameters-4)

- $listID - the list id you want to subscribe a user to. This encrypted &amp; hashed id can be found under View all lists section named ID
- $email - user's email

##### Example

[](#example-4)

```
try{
    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $subscriptionStatus = $sendy->getSubscriptionStatus('myHashedListID','mysubscribers@email.com');

    if($subscriptionStatus->success())
    {
        switch(true)
        {
            case $subscriptionStatus->isSubscribed():
                echo "Subscribed";
                break;
            case $subscriptionStatus->isUnSubscribed():
                echo "Unsubscribed";
                break;
            case $subscriptionStatus->isComplained():
                echo "Complained";
                break;
            case $subscriptionStatus->isUnconfirmed():
                echo "Unconfirmed";
                break;
            case $subscriptionStatus->isHardBounced():
                echo "Hard Bounced";
                break;
            case $subscriptionStatus->isSoftBounced():
                echo "Soft bounced";
                break;
        }
    }
    else
        echo "Ops! Sendy API responds a problem with getting subscribtion status - Sendy PHP message :".$subscriptionStatus->getRawResponse();

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-4)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\DomainException` is thrown if $listID is empty
- `\SendyPHP\Exception\InvalidEmailException` is thrown if email address is not valid
- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values-4)

`\SendyPHP\Response\SubscriptionStatus`returned object has many of usable methods (see phpdoc) f.e. by calling success() are you able to check if API returns some subscribers status.

#### Create campaign

[](#create-campaign)

Creates draft of campaign

```
bool createCampaign($brandID, Model\Campaign $campaign, &$statusMessage = NULL)
```

##### Parameters

[](#parameters-5)

- $brandID - Brand IDs can be found under 'Brands' page named ID
- $campaign &lt;\\SendyPHP\\Model\\Campaign&gt; - configured campaign
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example-5)

```
try{
    $sender = new \SendyPHP\Model\Sender('From name','from-adrress@mydomain.com','reply-address@mydomain.com');
    $emailBody = new \SendyPHP\Model\EmailBody('HTML body of my newsletter', 'Plaintext body of my newsletter');
    $campaign = new \SendyPHP\Model\Campaign($sender,'My first great newsletter!',$emailBody);
    $brandID = 1; // here fill your brand ID

    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $status = $sendy->createCampaign($brandID,$campaign,$statusMessage);

    if($status)
    {
        echo "Campaign successfully created";
    }
    else
        echo "Ops! Sendy API responds a problem with creating campaign - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-5)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request

##### Return values

[](#return-values-5)

Returns TRUE on success or FALSE on failure.

#### Send campaign

[](#send-campaign)

Creates draft and automatically sends campaign

```
bool sendCampaign(array $listIDs, Model\Campaign $campaign, &$statusMessage = NULL)
```

##### Parameters

[](#parameters-6)

- $listIDs &lt;number\[\]&gt; - The encrypted &amp; hashed ids can be found under View all lists section named ID.
- $campaign &lt;\\SendyPHP\\Model\\Campaign&gt; - configured campaign
- $statusMessage &lt;string|null&gt; - optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why

##### Example

[](#example-6)

```
try{
    $sender = new \SendyPHP\Model\Sender('From name','from-adrress@mydomain.com','reply-address@mydomain.com');
    $emailBody = new \SendyPHP\Model\EmailBody('HTML body of my newsletter', 'Plaintext body of my newsletter');
    $campaign = new \SendyPHP\Model\Campaign($sender,'My first great newsletter!',$emailBody);
    $listIDs = array(1); // here fill your list IDs

    $sendy = new \SendyPHP\Sendy('http://mysendyinstalation.mydomain','myAPIKey');

    $statusMessage = '';
    $status = $sendy->sendCampaign($listIDs,$campaign,$statusMessage);

    if($status)
    {
        echo "Campaign successfully created and now sending";
    }
    else
        echo "Ops! Sendy API responds a problem with creating and sending campaign - Sendy PHP message :".$statusMessage;

}catch (\SendyPHP\Exception $e)
{
    echo "Ops! An exception raised: ".$e;
}
```

##### Exceptions

[](#exceptions-6)

All exceptions are extended from `\SendyPHP\Exception` so you can easily catch just this parent class

- `\SendyPHP\Exception\CurlException` is thrown if cURL library could not handle your request
- `\SendyPHP\Exception\DomainException` is thrown if $listIDs array is empty

##### Return values

[](#return-values-6)

Returns TRUE on success or FALSE on failure.

### Other methods

[](#other-methods)

#### Set cURL option

[](#set-curl-option)

Sets cURL option You can set cURL options f.e. `CURLOPT_SSL_VERIFYPEER` or `CURLOPT_SSL_VERIFYHOST`some parameters (`\CURLOPT_RETURNTRANSFER`, `\CURLOPT_POST`, `\CURLOPT_POSTFIELDS`) are used, if you try to set one of these exception is thrown. See  for more informations.

```
void setCurlOption($option, $value)
```

##### Parameters

[](#parameters-7)

- $option - use `\CURLOPT_`\* constant
- $value mixed

##### Exceptions

[](#exceptions-7)

`\SendyPHP\Exception\UnexpectedValueException` is thrown if you try to set one of predefined options (`\CURLOPT_RETURNTRANSFER`, `\CURLOPT_POST` and `\CURLOPT_POSTFIELDS`).

#### Clear cURL option

[](#clear-curl-option)

Sets cURL option Clears user defined cURL options

```
void clearCurlOptions()
```

#### Set URL

[](#set-url)

Sets sendy installation URL Clears user defined cURL options

```
void setURL($URL)
```

##### Exceptions

[](#exceptions-8)

`\SendyPHP\Exception\InvalidURLException` is thrown if URL is invalid.

#### Set API key

[](#set-api-key)

Sets api key

```
void setApiKey($apiKey)
```

##### Parameters

[](#parameters-8)

- $apiKey - sendy API key - your API key is available in sendy Settings

##### Exceptions

[](#exceptions-9)

`\SendyPHP\Exception\DomainException` is thrown if API key is not string.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~230 days

Recently: every ~439 days

Total

9

Last Release

2424d ago

Major Versions

1.0.4 → 2.0.12016-11-28

2.0.3 → 4.0.3.32019-11-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9307011?v=4)[Jiří Riedl](/maintainers/jiririedl)[@jiririedl](https://github.com/jiririedl)

---

Top Contributors

[![jiririedl](https://avatars.githubusercontent.com/u/9307011?v=4)](https://github.com/jiririedl "jiririedl (7 commits)")[![gvidal](https://avatars.githubusercontent.com/u/820199?v=4)](https://github.com/gvidal "gvidal (4 commits)")

---

Tags

phpapiSendy

### Embed Badge

![Health badge](/badges/jiririedl-php-sendy/health.svg)

```
[![Health](https://phpackages.com/badges/jiririedl-php-sendy/health.svg)](https://phpackages.com/packages/jiririedl-php-sendy)
```

###  Alternatives

[corsinvest/cv4pve-api-php

Corsinvest Proxmox VE Client API PHP

811.4M](/packages/corsinvest-cv4pve-api-php)[mrkampf/proxmox-ve

Proxmox VE API Client

6040.8k](/packages/mrkampf-proxmox-ve)[platforg/adobe-connect

Provides a PHP Client to interact with the Adobe Connect's API

1510.3k2](/packages/platforg-adobe-connect)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
