PHPackages                             emailit/emailit-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. emailit/emailit-php

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

emailit/emailit-php
===================

PHP SDK for the Emailit Email API

v2.0.2(3mo ago)22.4k↑6550%[1 issues](https://github.com/emailit/emailit-php/issues)1MITPHPPHP ^8.1.0CI passing

Since Mar 3Pushed 3mo agoCompare

[ Source](https://github.com/emailit/emailit-php)[ Packagist](https://packagist.org/packages/emailit/emailit-php)[ Docs](https://emailit.com)[ RSS](/packages/emailit-emailit-php/feed)WikiDiscussions main Synced 3w ago

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

Emailit PHP
===========

[](#emailit-php)

[![Tests](https://camo.githubusercontent.com/2e154b5da6705d2b1a1ea19f3a4df33659d3a423725c07181cd13cd35c83f5ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656d61696c69742f656d61696c69742d7068702f74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d313131383237)](https://github.com/emailit/emailit-php/actions)[![Packagist Version](https://camo.githubusercontent.com/9f443b19ea70d7e18b99fdf35161ae5df014ad66049e993863779f2a2ecce83e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d61696c69742f656d61696c69742d7068703f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d313131383237)](https://packagist.org/packages/emailit/emailit-php)[![License](https://camo.githubusercontent.com/feb0a7eb45ae62919ff17804f2aae9a198079271bcca07cf374f8fa8fea63ac3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f656d61696c69742f656d61696c69742d7068703f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d313131383237)](https://github.com/emailit/emailit-php/blob/main/LICENSE)

The official PHP SDK for the [Emailit](https://emailit.com) Email API.

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

[](#requirements)

- PHP 8.1+
- [Guzzle](https://github.com/guzzle/guzzle) 7.5+

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

[](#installation)

```
composer require emailit/emailit-php
```

Getting Started
---------------

[](#getting-started)

```
require 'vendor/autoload.php';

$emailit = Emailit::client('your_api_key');

$email = $emailit->emails()->send([
    'from'    => 'hello@yourdomain.com',
    'to'      => ['user@example.com'],
    'subject' => 'Hello from Emailit',
    'html'    => 'Welcome!Thanks for signing up.',
]);

echo $email->id;     // em_abc123...
echo $email->status; // pending
```

All service methods return typed resource objects (`Email`, `Domain`, `Contact`, etc.) with direct property access -- just like the Stripe SDK.

Available Services
------------------

[](#available-services)

ServicePropertyDescriptionEmails`$emailit->emails()`Send, list, get, cancel, retry emailsDomains`$emailit->domains()`Create, verify, list, manage sending domainsAPI Keys`$emailit->apiKeys()`Create, list, manage API keysAudiences`$emailit->audiences()`Create, list, manage audiencesSubscribers`$emailit->subscribers()`Add, list, manage subscribers in audiencesTemplates`$emailit->templates()`Create, list, publish email templatesSuppressions`$emailit->suppressions()`Create, list, manage suppressed addressesEmail Verifications`$emailit->emailVerifications()`Verify email addressesEmail Verification Lists`$emailit->emailVerificationLists()`Create, list, get results, exportWebhooks`$emailit->webhooks()`Create, list, manage webhooksContacts`$emailit->contacts()`Create, list, manage contactsEvents`$emailit->events()`List and retrieve eventsUsage
-----

[](#usage)

### Emails

[](#emails)

#### Send an email

[](#send-an-email)

```
$email = $emailit->emails()->send([
    'from'    => 'hello@yourdomain.com',
    'to'      => ['user@example.com'],
    'subject' => 'Hello from Emailit',
    'html'    => 'Welcome!',
]);

echo $email->id;
echo $email->status;
```

#### Send with a template

[](#send-with-a-template)

```
$email = $emailit->emails()->send([
    'from'      => 'hello@yourdomain.com',
    'to'        => 'user@example.com',
    'template'  => 'welcome_email',
    'variables' => [
        'name'    => 'John Doe',
        'company' => 'Acme Inc',
    ],
]);
```

#### Send with attachments

[](#send-with-attachments)

```
$email = $emailit->emails()->send([
    'from'        => 'invoices@yourdomain.com',
    'to'          => 'customer@example.com',
    'subject'     => 'Your Invoice #12345',
    'html'        => 'Please find your invoice attached.',
    'attachments' => [
        [
            'filename'     => 'invoice.pdf',
            'content'      => base64_encode(file_get_contents('invoice.pdf')),
            'content_type' => 'application/pdf',
        ],
    ],
]);
```

#### Schedule an email

[](#schedule-an-email)

```
$email = $emailit->emails()->send([
    'from'         => 'reminders@yourdomain.com',
    'to'           => 'user@example.com',
    'subject'      => 'Appointment Reminder',
    'html'         => 'Your appointment is tomorrow at 2 PM.',
    'scheduled_at' => '2026-01-10T09:00:00Z',
]);

echo $email->status;       // scheduled
echo $email->scheduled_at; // 2026-01-10T09:00:00Z
```

#### List emails

[](#list-emails)

```
$emails = $emailit->emails()->list(['page' => 1, 'limit' => 10]);

foreach ($emails as $email) {
    echo $email->id . ' — ' . $email->status . "\n";
}

if ($emails->hasMore()) {
    // fetch next page
}
```

#### Cancel / Retry

[](#cancel--retry)

```
$emailit->emails()->cancel('em_abc123');
$emailit->emails()->retry('em_abc123');
```

---

### Domains

[](#domains)

```
// Create a domain
$domain = $emailit->domains()->create([
    'name' => 'example.com',
    'track_loads' => true,
    'track_clicks' => true,
]);
echo $domain->id;

// Verify DNS
$domain = $emailit->domains()->verify('sd_123');

// List all domains
$domains = $emailit->domains()->list();

// Get a domain
$domain = $emailit->domains()->get('sd_123');

// Update a domain
$domain = $emailit->domains()->update('sd_123', ['track_clicks' => false]);

// Delete a domain
$emailit->domains()->delete('sd_123');
```

---

### API Keys

[](#api-keys)

```
// Create an API key
$key = $emailit->apiKeys()->create([
    'name' => 'Production Key',
    'scope' => 'full',
]);
echo $key->key; // only available on create

// List all API keys
$keys = $emailit->apiKeys()->list();

// Get an API key
$key = $emailit->apiKeys()->get('ak_123');

// Update an API key
$emailit->apiKeys()->update('ak_123', ['name' => 'Renamed Key']);

// Delete an API key
$emailit->apiKeys()->delete('ak_123');
```

---

### Audiences

[](#audiences)

```
// Create an audience
$audience = $emailit->audiences()->create(['name' => 'Newsletter']);
echo $audience->id;
echo $audience->token;

// List audiences
$audiences = $emailit->audiences()->list();

// Get an audience
$audience = $emailit->audiences()->get('aud_123');

// Update an audience
$emailit->audiences()->update('aud_123', ['name' => 'Updated Newsletter']);

// Delete an audience
$emailit->audiences()->delete('aud_123');
```

---

### Subscribers

[](#subscribers)

Subscribers belong to an audience, so the audience ID is always the first argument.

```
// Add a subscriber
$subscriber = $emailit->subscribers()->create('aud_123', [
    'email' => 'user@example.com',
    'first_name' => 'John',
    'last_name' => 'Doe',
]);

// List subscribers in an audience
$subscribers = $emailit->subscribers()->list('aud_123');

// Get a subscriber
$subscriber = $emailit->subscribers()->get('aud_123', 'sub_456');

// Update a subscriber
$emailit->subscribers()->update('aud_123', 'sub_456', [
    'first_name' => 'Jane',
]);

// Delete a subscriber
$emailit->subscribers()->delete('aud_123', 'sub_456');
```

---

### Templates

[](#templates)

```
// Create a template
$result = $emailit->templates()->create([
    'name' => 'Welcome',
    'subject' => 'Welcome!',
    'html' => 'Hi {{name}}',
]);

// List templates
$templates = $emailit->templates()->list();

// Get a template
$template = $emailit->templates()->get('tem_123');

// Update a template
$emailit->templates()->update('tem_123', ['subject' => 'New Subject']);

// Publish a template
$emailit->templates()->publish('tem_123');

// Delete a template
$emailit->templates()->delete('tem_123');
```

---

### Suppressions

[](#suppressions)

```
// Create a suppression
$suppression = $emailit->suppressions()->create([
    'email' => 'spam@example.com',
    'type' => 'hard_bounce',
    'reason' => 'Manual suppression',
]);

// List suppressions
$suppressions = $emailit->suppressions()->list();

// Get a suppression
$suppression = $emailit->suppressions()->get('sup_123');

// Update a suppression
$emailit->suppressions()->update('sup_123', ['reason' => 'Updated']);

// Delete a suppression
$emailit->suppressions()->delete('sup_123');
```

---

### Email Verifications

[](#email-verifications)

```
$result = $emailit->emailVerifications()->verify([
    'email' => 'test@example.com',
]);

echo $result->status; // valid
echo $result->score;  // 0.95
echo $result->risk;   // low
```

---

### Email Verification Lists

[](#email-verification-lists)

```
// Create a verification list
$list = $emailit->emailVerificationLists()->create([
    'name' => 'Marketing List Q1',
    'emails' => [
        'user1@example.com',
        'user2@example.com',
        'user3@example.com',
    ],
]);
echo $list->id;     // evl_abc123...
echo $list->status; // pending

// List all verification lists
$lists = $emailit->emailVerificationLists()->list();

// Get a verification list
$list = $emailit->emailVerificationLists()->get('evl_abc123');
echo $list->stats['successful_verifications'];

// Get verification results
$results = $emailit->emailVerificationLists()->results('evl_abc123', ['page' => 1, 'limit' => 50]);

foreach ($results as $result) {
    echo $result->email . ' — ' . $result->result . "\n";
}

// Export results as XLSX
$response = $emailit->emailVerificationLists()->export('evl_abc123');
file_put_contents('results.xlsx', $response->body);
```

---

### Webhooks

[](#webhooks)

```
// Create a webhook
$webhook = $emailit->webhooks()->create([
    'name' => 'My Webhook',
    'url' => 'https://example.com/hook',
    'all_events' => true,
    'enabled' => true,
]);
echo $webhook->id;

// List webhooks
$webhooks = $emailit->webhooks()->list();

// Get a webhook
$webhook = $emailit->webhooks()->get('wh_123');

// Update a webhook
$emailit->webhooks()->update('wh_123', ['enabled' => false]);

// Delete a webhook
$emailit->webhooks()->delete('wh_123');
```

---

### Contacts

[](#contacts)

```
// Create a contact
$contact = $emailit->contacts()->create([
    'email' => 'user@example.com',
    'first_name' => 'John',
    'last_name' => 'Doe',
]);
echo $contact->id;

// List contacts
$contacts = $emailit->contacts()->list();

// Get a contact
$contact = $emailit->contacts()->get('con_123');

// Update a contact
$emailit->contacts()->update('con_123', ['first_name' => 'Jane']);

// Delete a contact
$emailit->contacts()->delete('con_123');
```

---

### Events

[](#events)

```
// List events
$events = $emailit->events()->list(['type' => 'email.delivered']);

foreach ($events as $event) {
    echo $event->type . "\n";
}

// Get an event
$event = $emailit->events()->get('evt_123');
echo $event->type;
echo $event->data['email_id'];
```

Webhook Events
--------------

[](#webhook-events)

The SDK provides typed event classes for all Emailit webhook event types under the `Emailit\Events` namespace, plus a `WebhookSignature` class for verifying webhook request signatures.

### Verifying Webhook Signatures

[](#verifying-webhook-signatures)

```
use Emailit\WebhookSignature;
use Emailit\Events\EmailDelivered;
use Emailit\Exceptions\ApiErrorException;

$rawBody = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_EMAILIT_SIGNATURE'];
$timestamp = $_SERVER['HTTP_X_EMAILIT_TIMESTAMP'];
$secret = 'your_webhook_signing_secret';

try {
    $event = WebhookSignature::verify($rawBody, $signature, $timestamp, $secret);

    // $event is automatically typed based on the event type
    echo $event->type;     // e.g. "email.delivered"
    echo $event->event_id; // e.g. "evt_abc123"

    // Access the event data
    $data = $event->getEventData();

    if ($event instanceof EmailDelivered) {
        // Handle delivered email
    }
} catch (ApiErrorException $e) {
    http_response_code(401);
    exit($e->getMessage());
}
```

You can disable replay protection by passing `tolerance: null`, or set a custom tolerance in seconds:

```
// Skip replay check
$event = WebhookSignature::verify($rawBody, $signature, $timestamp, $secret, tolerance: null);

// Custom 10-minute tolerance
$event = WebhookSignature::verify($rawBody, $signature, $timestamp, $secret, tolerance: 600);
```

### Available Event Types

[](#available-event-types)

**Emails:** `email.accepted`, `email.scheduled`, `email.delivered`, `email.bounced`, `email.attempted`, `email.failed`, `email.rejected`, `email.suppressed`, `email.received`, `email.complained`, `email.clicked`, `email.loaded`

**Domains:** `domain.created`, `domain.updated`, `domain.deleted`

**Audiences:** `audience.created`, `audience.updated`, `audience.deleted`

**Subscribers:** `subscriber.created`, `subscriber.updated`, `subscriber.deleted`

**Contacts:** `contact.created`, `contact.updated`, `contact.deleted`

**Templates:** `template.created`, `template.updated`, `template.deleted`

**Suppressions:** `suppression.created`, `suppression.updated`, `suppression.deleted`

**Email Verifications:** `email_verification.created`, `email_verification.updated`, `email_verification.deleted`

**Email Verification Lists:** `email_verification_list.created`, `email_verification_list.updated`, `email_verification_list.deleted`

Each event type has a corresponding class under `Emailit\Events\` (e.g. `Emailit\Events\EmailDelivered`, `Emailit\Events\DomainCreated`). You can use `instanceof` checks or the `EVENT_TYPE` constant for routing:

```
use Emailit\Events\EmailDelivered;
use Emailit\Events\EmailBounced;
use Emailit\Events\ContactCreated;

match (true) {
    $event instanceof EmailDelivered  => handleDelivered($event),
    $event instanceof EmailBounced    => handleBounce($event),
    $event instanceof ContactCreated  => handleNewContact($event),
    default                           => log("Unhandled: {$event->type}"),
};
```

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions for API errors:

```
use Emailit\Exceptions\AuthenticationException;
use Emailit\Exceptions\InvalidRequestException;
use Emailit\Exceptions\RateLimitException;
use Emailit\Exceptions\UnprocessableEntityException;
use Emailit\Exceptions\ApiConnectionException;
use Emailit\Exceptions\ApiErrorException;

try {
    $emailit->emails()->send([...]);
} catch (AuthenticationException $e) {
    // Invalid API key (401)
} catch (InvalidRequestException $e) {
    // Bad request or not found (400, 404)
} catch (RateLimitException $e) {
    // Too many requests (429)
} catch (UnprocessableEntityException $e) {
    // Validation failed (422)
} catch (ApiConnectionException $e) {
    // Network error
} catch (ApiErrorException $e) {
    // Any other API error
    echo $e->getHttpStatus();
    echo $e->getHttpBody();
    print_r($e->getJsonBody());
}
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE) for details.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance69

Regular maintenance activity

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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 ~0 days

Total

2

Last Release

112d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed5d6f241e07f3cdd1b6b8827d47b86785b88100a30376f79c274533ae601aad?d=identicon)[CodeSkills](/maintainers/CodeSkills)

---

Top Contributors

[![CodeSkills](https://avatars.githubusercontent.com/u/3975293?v=4)](https://github.com/CodeSkills "CodeSkills (18 commits)")

---

Tags

apisdkemailemailit

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

15122.2k](/packages/hafael-azure-mailer-driver)

PHPackages © 2026

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