Skip to main content

Instantiation

Your API key is read from the PAUBOX_API_KEY environment variable. The SDK does not load .env files itself (see Authentication). No constructor arguments are needed.

Building a message

A message is assembled from three objects (Header, Content, and Message) plus optional Attachment objects.

Content

Message

Attachments

Send a message

The response is a stdClass object:

Check delivery status

$disposition->data->message->message_deliveries is an array of per-recipient objects:
Common deliveryStatus values: delivered, delivered via secure portal, soft bounced, hard bounced, processing. Opens are reported separately in openedStatus.

Scheduled send

Schedule a message for future delivery, check its status, reschedule, or cancel it.

Schedule a message

$scheduledAt must be an ISO 8601 UTC datetime string in the future and within 30 days.

Get scheduled message status

Reschedule a message

Cancel a scheduled message

In paubox-php 1.5.1 through 2.0.0, cancelScheduledMessage throws a TypeError from its HTTP library (mb_strlen(): Argument #1 ($string) must be of type string, array given) before the request is sent, so the message stays scheduled.

Error handling

sendMessage throws \Exception if the Header or Content is null, or if the API response is not JSON. getEmailDisposition throws if the response is not JSON. Neither method throws on HTTP error statuses: an API error is returned as a decoded object with an errors property, so check it: