Skip to main content
The PHP SDK is the sendflit/sendflit Composer package. It uses PHP’s curl extension and json extension, and has no other dependencies. It requires PHP 7.4 or later.
Looking for another language? See the SDK overview.

Install

Requires PHP 7.4 or later with the curl and json extensions.

Create a client

The constructor takes these arguments:

Send an email

send takes an associative array and returns the response as an array.
The array keys match the API’s field names:

Send with a template

Attachments

Each attachment is an array with filename, content and an optional content_type. The SDK base64-encodes content for you. Pass the raw file contents, not a path.
Limits:
  • Up to 10 attachments per message.
  • Up to 10 MB per attachment. Larger files are rejected with 422.

Send a batch

batch sends up to 100 emails in one request. It takes an array of arrays, each with the same keys as send.
The response has a results array in the same order as your input, and a count. An empty array throws InvalidArgumentException, and more than 100 emails throws RangeException, before any request is made. See Batch sending.
The PHP SDK doesn’t send an Idempotency-Key header yet, so a retried send can deliver twice. Check the earlier result before you retry. See Idempotency.

Manage emails

cancelEmail removes an email that hasn’t been sent yet. If the email was already sent, the API returns an error, which the SDK throws as SendFlitException.

Domains

You can send only from a verified domain. For DNS setup, see Domains.

Suppressions

The second argument is optional and defaults to 'unsubscribe'. See Emails.

Usage and health

Verify webhooks

SendFlit signs each webhook. The X-Sendflit-Signature header carries sha256=<hex>, an HMAC-SHA256 of the raw request body.
The check uses hash_equals, which runs in constant time. Read php://input before anything else touches the request body. See Webhooks for the event list.

Errors and retries

Every failed request throws SendFlitException:
Requests that fail with 429 or 5xx are retried up to $maxRetries times, with exponential backoff. Other 4xx responses are not retried. See Errors, retries and limits.

Method reference

Next steps