PHPackages                             freshmail/rest-api - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. freshmail/rest-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

freshmail/rest-api
==================

A php library which implements the functionality of FreshMail REST API.

v4.0.0(2y ago)14198.2k↓39.9%16[3 issues](https://github.com/FreshMail/REST-API/issues)[1 PRs](https://github.com/FreshMail/REST-API/pulls)1GPL-3.0PHPPHP &gt;=7.0||^8.0CI failing

Since Sep 15Pushed 2y ago3 watchersCompare

[ Source](https://github.com/FreshMail/REST-API)[ Packagist](https://packagist.org/packages/freshmail/rest-api)[ RSS](/packages/freshmail-rest-api/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (1)

FreshMail
=========

[](#freshmail)

A php library which implements connection to FreshMail REST API.

This API client covers all functions of API V2 such as:

- subscribers management
- list management
- campaign management
- sending transactional SMS messages

If You want to send transactional messages in rich format please use new [API V3 client](https://github.com/FreshMail/php-api-client).

Installation via composer (compatible with PHP &gt;=8.0)
--------------------------------------------------------

[](#installation-via-composer-compatible-with-php-80)

Add via composer:

```
composer require freshmail/rest-api:^4.0

```

Installation via composer (compatible with PHP &gt;=7.0)
--------------------------------------------------------

[](#installation-via-composer-compatible-with-php-70)

Add via composer:

```
composer require freshmail/rest-api:^3.0

```

Installation of old version of library (compatible with PHP &gt;=5.3)
---------------------------------------------------------------------

[](#installation-of-old-version-of-library-compatible-with-php-53)

Add via composer:

```
composer require freshmail/rest-api:^2.0

```

Usage
-----

[](#usage)

Below some simple examples, for whole API function see [full API V2 doc](https://freshmail.pl/developer-api/jak-zaczac/)

#### Test connection

[](#test-connection)

```
use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$apiClient->doRequest('ping');

```

#### Create subscribers list

[](#create-subscribers-list)

```
use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'name' => 'List with subscribers from my website'
];

$apiClient->doRequest('subscribers_list/create', $data);

```

#### Add subscriber to list

[](#add-subscriber-to-list)

```
use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'email' => 'example@email.address',
    'list' => 'list_hash'
];

$apiClient->doRequest('subscriber/add', $data);

```

#### Get file from async api

[](#get-file-from-async-api)

```
use \FreshMail\ApiV2\Client;

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);

$data = [
    'id_job' => 'XXX'
];

$zipContent = $apiClient->doFileRequest('async_result/getFile', $data);

file_put_contents('/testLocation/testfile.zip', $zipContent);

```

Proxy setup
-----------

[](#proxy-setup)

To use proxy You can pass Your own GuzzleHttp Client:

```
use \FreshMail\ApiV2\Client;

$guzzleClient = new \GuzzleHttp\Client(
    [
        'proxy' => 'my proxy url'
    ]
);

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setGuzzleHttpClient($guzzleClient);

```

Debugging
---------

[](#debugging)

#### PSR-3 Logger Interface

[](#psr-3-logger-interface)

You can use any library that implements [PSR-3](https://www.php-fig.org/psr/psr-3/) `Psr\Log\LoggerInterface`, example with Monolog below:

```
use \FreshMail\ApiV2\Client;

$logger = new \Monolog\Logger('myCustomLogger');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stderr', \Monolog\Logger::DEBUG));

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setLogger($monolog);

```

#### Using Guzzle

[](#using-guzzle)

You can also pass Your own GuzzleHttp Client with proper configuration:

```
use \FreshMail\ApiV2\Client;

$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(
    \GuzzleHttp\Middleware::log(
        new \Monolog\Logger('Logger'),
        new \GuzzleHttp\MessageFormatter(\GuzzleHttp\MessageFormatter::DEBUG)
    )
);

$guzzleClient = new \GuzzleHttp\Client(
    [
        'handler' => $stack,
    ]
);

$token = 'MY_APP_TOKEN';
$apiClient = new Client($token);
$apiClient->setGuzzleHttpClient($guzzleClient);

```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 55.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 ~302 days

Recently: every ~283 days

Total

10

Last Release

859d ago

Major Versions

v1.0 → v2.02017-02-19

v2.0.2 → v3.0.02020-05-20

v3.2.2 → v4.0.02024-02-26

PHP version history (3 changes)v1.0PHP &gt;=5.3.0

v3.0.0PHP &gt;=7.0

v4.0.0PHP &gt;=7.0||^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/88144ec17acb17a03afc8cfb25af50bd56d560c4f15517db86ab26a4b2882169?d=identicon)[FreshMail](/maintainers/FreshMail)

---

Top Contributors

[![grzesiekgorczyca](https://avatars.githubusercontent.com/u/8577651?v=4)](https://github.com/grzesiekgorczyca "grzesiekgorczyca (10 commits)")[![ankalagon](https://avatars.githubusercontent.com/u/532333?v=4)](https://github.com/ankalagon "ankalagon (5 commits)")[![FreshMailAPP](https://avatars.githubusercontent.com/u/8984733?v=4)](https://github.com/FreshMailAPP "FreshMailAPP (1 commits)")[![fugi](https://avatars.githubusercontent.com/u/4803401?v=4)](https://github.com/fugi "fugi (1 commits)")[![kamil-eichelberger-neuca](https://avatars.githubusercontent.com/u/84322434?v=4)](https://github.com/kamil-eichelberger-neuca "kamil-eichelberger-neuca (1 commits)")

---

Tags

restfreshmail

### Embed Badge

![Health badge](/badges/freshmail-rest-api/health.svg)

```
[![Health](https://phpackages.com/badges/freshmail-rest-api/health.svg)](https://phpackages.com/packages/freshmail-rest-api)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)

PHPackages © 2026

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