lemonade/component-smartemailing

Modern PHP client for the SmartEmailing v3 API. Includes typed models, collections, a safe HTTP wrapper, and a high-level SmartEmailingClient.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/lemonade/component-smartemailing

v1.2.0 2025-12-03 13:25 UTC

This package is auto-updated.

Last update: 2025-12-03 13:26:14 UTC


README

License PHP Version Packagist Version

Lemonade SmartEmailing API Client is a fully typed PHP 8.1+ wrapper for the SmartEmailing v3 REST API.
It provides high-level models, formatting helpers, strict typing, and a clean architecture that transforms raw API responses into structured domain objects.

Features

  • PHP 8.1+
  • Typed data models (contacts, lists, metadata, metrics, engagement)
  • Unified formatting layer converting raw API responses into structured arrays
  • High-level client API (SmartEmailingClient)
  • Supports:
    • retrieving lists and contacts
    • validating credentials
    • adding/updating contacts
    • deleting contacts
    • listing contacts by list
  • Compatible with PHPStan (strict mode)
  • Zero external dependencies besides Guzzle

Installation

Use Composer:

composer require lemonade/component_smartemailing

Quick Start

Initialize the API client

use Lemonade\SmartEmailing\Api\SmartEmailingApi;
use Lemonade\SmartEmailing\SmartEmailingClient;

$api = new SmartEmailingApi(
    user: 'YOUR_SMARTEMAILING_LOGIN',
    token: 'YOUR_SMARTEMAILING_TOKEN'
);

$client = new SmartEmailingClient($api);

Validate Credentials

$response = $client->checkLogin();

if ($response->success) {
    echo "API login OK";
} else {
    echo "Login failed: " . $response->message;
}

Retrieve Lists

$lists = $client->getLists();

foreach ($lists as $list) {
    echo $list->getId() . " - " . $list->getName();
}

Retrieve Contacts

$contacts = $client->getContacts();

foreach ($contacts as $contact) {
    echo $contact->getEmail();
}

Add or Update Contact

$response = $client->addOrUpdate(
    email: 'john@example.com',
    listId: 2,
    fields: [
        'name' => 'John',
        'surname' => 'Doe',
        'language' => 'cs_CZ'
    ]
);

if ($response->success) {
    echo "Contact saved.";
}

Get Contacts from List

$listContacts = $client->getContactsByList(2);

foreach ($listContacts as $c) {
    echo $c->getEmail();
}

Delete Contact

$client->removeFromList(123);

License

MIT License © Lemonade Framework