Search by

emercurymail / smtp-sdk

roman-emercury

Official PHP SDK for the Emercury SMTP API

v1.0.1 2026-07-27 07:23 UTC

This package is auto-updated.

Last update: 2026-09-16 18:06:18 UTC


README

The official PHP client for sending transactional email and reading outbound delivery statistics through the stable Emercury SMTP API.

Requirements

  • PHP 8.1 or newer
  • cURL, JSON, and mbstring extensions

Installation

composer require emercurymail/smtp-sdk

Send an email

<?php

use Emercury\SmtpSdk\Api\EmailApi;
use Emercury\SmtpSdk\Configuration;
use Emercury\SmtpSdk\Model\EmailAddress;
use Emercury\SmtpSdk\Model\EmailContentPart;
use Emercury\SmtpSdk\Model\SendEmailRequest;
use GuzzleHttp\Client;

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

$configuration = Configuration::getDefaultConfiguration()
    ->setApiKey('X-Emercury-Token', getenv('EMERCURY_API_TOKEN'));

$email = new SendEmailRequest([
    'from' => new EmailAddress(['email' => 'sender@example.com', 'name' => 'Example']),
    'to' => new EmailAddress(['email' => 'recipient@example.net']),
    'subject' => 'Hello from Emercury',
    'contents' => [new EmailContentPart([
        'content_type' => 'text/plain',
        'content' => 'Your transactional email is ready.',
    ])],
]);

$result = (new EmailApi(new Client(), $configuration))->sendEmail(
    $email,
    idempotency_key: '01992ee0-31a6-783c-bd0d-2677ef418ee8',
);

Use a unique idempotency key when a send may be retried. The same key and normalized payload return the original response for 24 hours; reusing a key with a different payload returns 409 Conflict.