Learn how to install and use the SendLayer PHP SDK.
.php
file. Then import and initialize the client with your API key.
html
parameter when calling send()
.
text
parameter to provide both plain text and HTML versions of your email.name
and email
.
attachments
parameter in the payload.
Parameter | Type | Required | Description |
---|---|---|---|
to | string or array | Yes | Email address(es) of the recipient(s). Can be a single string or an array of objects with email and name |
from | string or array | Yes | Email address of the sender. Can be a single string or an object with email and name |
subject | string | Yes | Subject line of the email |
text | string | No | Plain text version of the email content |
html | string | No | HTML version of the email content |
cc | array | No | Array of objects for CC recipients |
bcc | array | No | Array of objects for BCC recipients |
replyTo | array | No | Array of objects for reply-to addresses |
attachments | array | No | Array of objects with file path and MIME type |
tags | array | No | Array of strings used to tag emails |
headers | array | No | Associative array of custom headers |
Webhooks->create()
with required parameters url
and event
.
event
parameter accepts the following options:
Webhooks->get()
to view all webhooks you’ve created.
Webhooks->delete()
with the numeric webhookId
.
Webhooks
module.
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Yes | The webhook endpoint URL where events will be sent |
event | string | Yes | The type of event to listen for. Options: bounce, click, open, unsubscribe, complaint, delivery |
webhookId | integer | Yes | Unique identifier for the webhook (used in delete operation) |
Events->get()
to retrieve events.
Events->get()
method retrieves the top 5 events if no filters are specified.Events
module.
Parameter | Type | Required | Description |
---|---|---|---|
startDate | DateTime or int | No | Start date for filtering events (Unix timestamp or DateTime) |
endDate | DateTime or int | No | End date for filtering events (Unix timestamp or DateTime) |
event | string | No | Filter by event type. Supported: accepted , rejected , delivered , opened , clicked , unsubscribed , complained , failed |
messageId | string | No | Filter by the email MessageId |
startFrom | integer | No | Starting position for pagination |
retrieveCount | integer | No | Number of event records to retrieve (defaults to 5) |
SendLayerException
: Base exception for all SendLayer errorsSendLayerAuthenticationException
: Invalid API key or authentication issuesSendLayerValidationException
: Invalid parameters or validation errorsSendLayerAPIException
: API-specific errors with status code and response data