emercurymail / smtp-sdk
Official PHP SDK for the Emercury SMTP API
v1.0.1
2026-07-27 07:23 UTC
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.6
Requires (Dev)
- phpunit/phpunit: ^10.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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.