PHPackages                             s-mailer/sdk - 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. s-mailer/sdk

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

s-mailer/sdk
============

PHP SDK for the S-Mailer API — send messages, manage webhooks, and more

v0.1.0(yesterday)01↑2900%MITPHPPHP &gt;=8.1CI passing

Since Jul 28Pushed todayCompare

[ Source](https://github.com/s-mailer/sdk-php)[ Packagist](https://packagist.org/packages/s-mailer/sdk)[ Docs](https://mailer.smartek.co.mz)[ RSS](/packages/s-mailer-sdk/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

S-Mailer PHP SDK
================

[](#s-mailer-php-sdk)

PHP SDK for the [S-Mailer](https://mailer.smartek.co.mz) API — send messages across SMS, email, WhatsApp and more, list sent/received messages, check your balance, and verify webhooks.

> **Status: pre-1.0.** All resource methods are implemented; the API may still change before `1.0.0`.

Requirements
------------

[](#requirements)

- PHP 8.1+
- A [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client and [PSR-17](https://www.php-fig.org/psr/psr-17/) factories (e.g. Guzzle). They are auto-discovered via [`php-http/discovery`](https://docs.php-http.org/en/latest/discovery.html); you can also inject your own (see [Configuration](#configuration)).

Installation
------------

[](#installation)

```
composer require s-mailer/sdk
```

If you don't already have a PSR-18 client installed:

```
composer require guzzlehttp/guzzle
```

Authentication
--------------

[](#authentication)

Every request authenticates with your `X-Client-ID` / `X-Client-Secret` pair. Find them in your [S-Mailer dashboard](https://mailer.smartek.co.mz).

```
$mailer = new \SMailer\Client('CLT-XXXXXXXX', 'your-api-secret');
```

Usage
-----

[](#usage)

### Send a message

[](#send-a-message)

```
$result = $mailer->messages->send([
    'sender'    => 'sms-co1-xxxxxxxx',
    'recipients' => [
        '+258841234567',
        ['phone' => '+258842000001', 'data' => ['name' => 'Alice']],
    ],
    'content_template' => 'Hi ${name}, your code is ${code}.',
    // 'channel' => 'sms', 'provider' => 'sms-co1',  // alternatives to `sender`
    // 'campaign_id' => 'promo-2026',
    // 'webhook_url' => 'https://your-app.com/webhooks/status',
]);
// => ['message_id' => ..., 'external_id' => ..., 'total_cost_tokens' => ...]
```

### List and fetch messages

[](#list-and-fetch-messages)

```
$sent = $mailer->messages->listOutbound(['status' => 'delivered', 'channel' => 'sms', 'limit' => 50]);
$received = $mailer->messages->listInbound(['limit' => 50]);
$one = $mailer->messages->get($messageId);   // outbound or inbound; see `direction`
```

### Retrigger / delete

[](#retrigger--delete)

```
$mailer->messages->retrigger($inboundId); // unlock + re-deliver a locked (unpaid) inbound
$mailer->messages->delete($messageId);    // delete an outbound or paid inbound message
```

### Balance, profile, channels

[](#balance-profile-channels)

```
$tokens   = $mailer->balance->get();       // int
$profile  = $mailer->balance->profile();   // includes webhook_signing_key
$channels = $mailer->channels->list();     // public senders + your private ones (authenticated)
```

Configuration
-------------

[](#configuration)

Pass a third `$options` array to tune the client:

```
$mailer = new \SMailer\Client('CLT-XXXXXXXX', 'your-api-secret', [
    'baseUrl'    => 'https://api.mailer.smartek.co.mz', // override the API host
    'maxRetries' => 2,                                  // retry 429/5xx/network (default 2)

    // Inject your own PSR-18 client / PSR-17 factories instead of auto-discovery:
    // 'httpClient'     => $psr18Client,
    // 'requestFactory' => $psr17RequestFactory,
    // 'streamFactory'  => $psr17StreamFactory,
]);
```

Retries use an exponential backoff and honour a `Retry-After` header on `429`.

Webhooks
--------

[](#webhooks)

S-Mailer signs every webhook it sends with `X-Mailer-Signature: hex(HMAC-SHA256(webhook_signing_key, raw_body))`. Your `webhook_signing_key` comes from `GET /api/v1/client` (`$mailer->balance->profile()`). **Verify over the raw request body, before decoding it.**

```
$raw = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_MAILER_SIGNATURE'] ?? '';

$event = (new \SMailer\Webhook())->parse($raw, $sig, $signingKey); // throws on bad signature
if (($event['payment_required'] ?? false) === false) {
    // handle inbound message / status update
}
```

Two payload shapes are delivered, distinguished by their fields:

- **Inbound:** `{ id, from, to, channel, body, received_at, sender_id, client_id, payment_required }`
- **Status:** `{ message_id, recipient, status: { old, current }, error_code, timestamp }`

Errors
------

[](#errors)

Non-2xx responses raise a `\SMailer\Exception\SMailerException` subclass carrying the API `error` code (`->errorCode`) and HTTP status (`->statusCode`):

StatusException (`\SMailer\Exception\…`)`error`401`AuthenticationException``AUTHENTICATION_FAILED`403`ForbiddenException``FORBIDDEN`400`BadRequestException` / `ValidationException``BAD_REQUEST` / `VALIDATION_ERROR`402`InsufficientTokensException``INSUFFICIENT_TOKENS`404`NotFoundException``NOT_FOUND`429`RateLimitException` (`->retryAfter`)`RATE_LIMIT_EXCEEDED`5xx`ServerException``INTERNAL_SERVER_ERROR`Network/transport failures raise `NetworkException`.

```
use SMailer\Exception\InsufficientTokensException;
use SMailer\Exception\RateLimitException;

try {
    $mailer->messages->send([/* ... */]);
} catch (InsufficientTokensException $e) {
    // top up the account
} catch (RateLimitException $e) {
    sleep($e->retryAfter ?? 1);
}
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/130801183?v=4)[Arlindo Abdul](/maintainers/lizzyman04)[@lizzyman04](https://github.com/lizzyman04)

---

Top Contributors

[![lizzyman04](https://avatars.githubusercontent.com/u/130801183?v=4)](https://github.com/lizzyman04 "lizzyman04 (3 commits)")

---

Tags

apisdkemailsmsmessagingwhatsapps-mailer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/s-mailer-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/s-mailer-sdk/health.svg)](https://phpackages.com/packages/s-mailer-sdk)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36789.4k2](/packages/telnyx-telnyx-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k17](/packages/tempest-framework)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M326](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)

PHPackages © 2026

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