sendkit / sendkit-php
PHP SDK for the SendKit email API
1.0.5
2026-03-12 01:23 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- pestphp/pest: ^3.0
README
Official PHP SDK for the SendKit email API.
Installation
composer require sendkit/sendkit-php
Usage
Create a Client
use SendKit\SendKit; $client = SendKit::client('your-api-key');
Send an Email
$response = $client->emails()->send([ 'from' => 'you@example.com', 'to' => 'recipient@example.com', 'subject' => 'Hello from SendKit', 'html' => '<h1>Welcome!</h1>', ]); echo $response['id']; // Email ID
Send a MIME Email
$response = $client->emails()->sendMime( envelopeFrom: 'you@example.com', envelopeTo: 'recipient@example.com', rawMessage: $mimeString, ); echo $response['id'];
Validate an Email
$result = $client->validateEmail('recipient@example.com'); $result['is_valid']; // true or false $result['should_block']; // true if the email should be blocked $result['block_reason']; // reason for blocking, or null $result['evaluations']; // detailed evaluation results
The evaluations array contains:
has_valid_syntax— whether the email has valid syntaxhas_valid_dns— whether the domain has valid DNS recordsmailbox_exists— whether the mailbox existsis_role_address— whether it's a role address (e.g. info@, admin@)is_disposable— whether it's a disposable emailis_random_input— whether it appears to be random input
Note: Each validation costs credits. A
SendKitExceptionwith status 402 is thrown when credits are insufficient.
Error Handling
use SendKit\Exceptions\SendKitException; try { $client->emails()->send([...]); } catch (SendKitException $e) { echo $e->getMessage(); // Error message echo $e->status; // HTTP status code }