PHP SDK
Packagist: coffeemail/coffeemail-php v0.1.0Full reference for the official coffeemail/coffeemail-php package for modern PHP (8.2+). Strict typing, safe data, error returns, tuple destructuring and cryptographic webhook validation.
Looking for Node.js or TypeScript docs? Check the official reference for the @coffeemail/node package.
Client Initialization
The API key is automatically resolved from the COFFEEMAIL_API_KEY environment variable if omitted from the constructor.
$client = new CoffeeMail(?string $apiKey = null, string $locale = 'pt-BR', int $timeoutSeconds = 10);Tuple Destructuring and Safe Returns
Safe Pattern { data, error }Operations return a CoffeeMailResponse instance allowing direct [$data, $error] destructuring or calling ->unwrap() to throw typed exceptions.
Cryptographic Webhook Verification
The Webhooks::verifySignature method validates the HMAC SHA-256 signature in the x-coffeemail-signature header using constant-time comparison against timing attacks.
Methods Catalog
Reference of operations available in the official PHP client.
Emails
$client->emails->send(array $payload): CoffeeMailResponse$client->emails->sendBatch(array $items): CoffeeMailResponse$client->emails->get(string $id): CoffeeMailResponse$client->emails->list(array $query = []): CoffeeMailResponseDomains
$client->domains->create(array $payload): CoffeeMailResponse$client->domains->verify(string $id): CoffeeMailResponseTemplates
$client->templates->preview(string $id, array $variables = []): CoffeeMailResponseWebhooks
Webhooks::verifySignature(string $payload, string $signature, string $secret): boolMetrics
$client->stats->get(array $query = []): CoffeeMailResponse