PHPackages                             mattstein/unsend-php - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. mattstein/unsend-php

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mattstein/unsend-php
====================

Unofficial Unsend PHP library.

1.1.0(9mo ago)0621MITPHPPHP ^8.1.0CI passing

Since Aug 7Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/mattstein/unsend-php)[ Packagist](https://packagist.org/packages/mattstein/unsend-php)[ RSS](/packages/mattstein-unsend-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (1)

Unsend PHP Library
==================

[](#unsend-php-library)

An unofficial SDK for [Unsend](https://unsend.dev).

[![Unsend + PHP](https://raw.githubusercontent.com/mattstein/unsend-php/refs/heads/main/assets/unsend-banner.png)](https://raw.githubusercontent.com/mattstein/unsend-php/refs/heads/main/assets/unsend-banner.png)

> On non-2xx responses, methods throw `\Unsend\Exceptions\ApiException` with parsed message and status code.

Installation &amp; Usage
------------------------

[](#installation--usage)

Install via Composer:

```
composer require mattstein/unsend-php

```

Create a client instance with your API key and specify your Unsend domain if you self host:

```
// Initialize via factory
$unsend = \Unsend\Unsend::create('your-api-key', 'https://app.unsend.dev');
```

You can then use any of the included methods to interact with the API, where `getData()` provides decoded response data and `getResponseObject()` provides the entire Guzzle response:

```
// Send an email
$response = $unsend->sendEmail([
    'to' => 'hello@example.tld',
    'from' => 'reply@example.tld',
    'subject' => 'Library Test Email',
    'html' => 'This is a test!',
    'text' => 'This is a test!'
]);

// Print email ID
echo $response->getData()->emailId;
```

Methods
-------

[](#methods)

Available methods follow the [API Reference](https://docs.unsend.dev/api-reference/introduction).

### `getEmail(string $emailId)`

[](#getemailstring-emailid)

Returns a single email record by ID.

```
$response = $unsend->getEmail('cxbkzjgku000xmw2tg7lndauk');

echo $response->getData()->subject;
```

### `listEmails(array $parameters = [])`

[](#listemailsarray-parameters--)

Returns an array of email records, optionally filtered by parameters.

```
$response = $unsend->listEmails([
    'domainId' => 3,
]);

foreach ($response->getData()->data as $email) {
    echo $email->subject . "\n";
}
```

### `iterateEmails(array $parameters = [])`

[](#iterateemailsarray-parameters--)

Lazy iterator for `listEmails()` that continues through pagination instead of returning pagination metadata.

```
foreach ($unsend->iterateEmails(['domainId' => 3]) as $email) {
    echo $email->subject . "\n";
}
```

### `sendEmail(array $parameters)`

[](#sendemailarray-parameters)

Sends an email.

```
$response = $unsend->sendEmail([
    'to' => 'hello@example.tld',
    'from' => 'reply@example.tld',
    'subject' => 'Library Test Email',
    'html' => 'This is a test!',
    'text' => 'This is a test!'
]);

echo $response->getData()->emailId;
```

### `batchEmail(array $parameters)`

[](#batchemailarray-parameters)

Sends up to 100 emails in one request.

### `updateSchedule(string $emailId, string $scheduledAt)`

[](#updateschedulestring-emailid-string-scheduledat)

Updates the targeted send time for a scheduled email.

```
$response = $unsend->sendEmail([
    'to' => 'hello@example.tld',
    'from' => 'reply@example.tld',
    'subject' => 'Library Test Email',
    'html' => 'This is a test!',
    'text' => 'This is a test!',
    'scheduledAt' => '2025-06-10T00:00:00Z'
]);

$scheduledEmailId = $response->getData()->emailId;

$unsend->updateSchedule($scheduledEmailId, '2025-06-07T00:00:00Z');
```

### `cancelSchedule(string $emailId)`

[](#cancelschedulestring-emailid)

Cancels a scheduled email.

```
$unsend->cancelSchedule('cxbkzjgku000xmw2tg7lndauk');
```

### `getContact(string $contactBookId, string $contactId)`

[](#getcontactstring-contactbookid-string-contactid)

Returns a single contact record.

```
$response = $unsend->getContact(
    'cxb19a523000foa3ctrd5h7u7',
    'cxb19bmdv000hoa3c3jfpx51t'
);

echo $response->getData()->email;
```

### `getContacts(string $contactBookId, array $parameters = [])`

[](#getcontactsstring-contactbookid-array-parameters--)

Returns an array of contact records, optionally filtered by parameters.

```
$response = $unsend->getContacts('cxb19a523000foa3ctrd5h7u7');

foreach ($response->getData() as $contact) {
    echo $contact->email . "\n";
}
```

### `createContact(string $contactBookId, array $parameters)`

[](#createcontactstring-contactbookid-array-parameters)

Creates a contact record.

```
$response = $unsend->createContact(
    'cxb19a523000foa3ctrd5h7u7',
    [
        'email' => 'gobiasindustries@example.com',
        'firstName' => 'Tobias',
        'lastName' => 'Fünke',
        'subscribed' => true,
    ]
);

echo $response->getData()->contactId;
```

### `updateContact(string $contactBookId, string $contactId, array $parameters = [])`

[](#updatecontactstring-contactbookid-string-contactid-array-parameters--)

Updates a contact record.

```
$unsend->updateContact(
    'cxb19a523000foa3ctrd5h7u7',
    'cxb19bmdv000hoa3c3jfpx51t',
    [
        'firstName' => 'Surely',
        'lastName' => 'Fünke',
    ]
);
```

### `upsertContact(string $contactBookId, string $contactId, array $parameters = [])`

[](#upsertcontactstring-contactbookid-string-contactid-array-parameters--)

Upserts a contact record.

### `deleteContact(string $contactBookId, string $contactId)`

[](#deletecontactstring-contactbookid-string-contactid)

Deletes a contact record.

```
$unsend->deleteContact('cxb19a523000foa3ctrd5h7u7', 'cxb19bmdv000hoa3c3jfpx51t');
```

### `getDomain(int $id)`

[](#getdomainint-id)

Returns a single domain record.

### `getDomains()`

[](#getdomains)

Returns an array of domain records.

```
$response = $unsend->getDomains();

foreach ($response->getData() as $domain) {
    echo $domain->name . "\n";
}
```

### `createDomain(array $parameters)`

[](#createdomainarray-parameters)

Creates a domain record.

```
$response = $unsend->createDomain(
    [
        'name' => 'example.com',
        'region' => 'us-east-1',
    ]
);

echo $response->getData()->id;
```

### `verifyDomain(int $id)`

[](#verifydomainint-id)

Attempts to verify a domain.

```
$response = $unsend->verifyDomain(5);

echo $response->getData()->message;
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance57

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

2

Last Release

282d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e0d8e8a2b2564922c84a3e8e552d6da91645aceb3121938b3c5ef1037429ff7?d=identicon)[mattstein](/maintainers/mattstein)

---

Top Contributors

[![mattstein](https://avatars.githubusercontent.com/u/2488775?v=4)](https://github.com/mattstein "mattstein (33 commits)")

---

Tags

emailsesunsend

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mattstein-unsend-php/health.svg)

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

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)

PHPackages © 2026

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