KMP PHP API Reference

ResendApiTransport extends ApiTransport
in package

Email transport for the Resend API.

Config keys:

  • apiKey: Resend API key (starts with "re_")
  • endpoint: API URL (default: https://api.resend.com/emails)
  • timeout: HTTP timeout in seconds (default: 30)
Tags
see
https://resend.com/docs/api-reference/emails/send-email

Table of Contents

Properties

$_defaultConfig  : array<string, mixed>
$httpClient  : Client|null

Methods

send()  : array<string|int, mixed>
setHttpClient()  : static
Set a custom HTTP client (useful for testing).
assertSuccessResponse()  : void
Assert a successful HTTP response or throw.
buildResult()  : array{headers: string, message: string}
Build the standard return value for send().
checkRecipient()  : void
Validate that the message has at least one recipient.
formatAttachments()  : array<int, array{name: string, contentType: string, content: string}>
Convert Message attachments to a provider-neutral format.
formatRecipients()  : array<int, array{email: string, name: string}>
Convert Message address array to a flat list of recipient objects.
getHttpClient()  : Client
Get or create the HTTP client instance.
getSender()  : array{email: string, name: string}
Get the sender address from a Message.
buildPayload()  : array<string|int, mixed>
Build the Resend API request payload.

Properties

$_defaultConfig

protected array<string, mixed> $_defaultConfig = ['apiKey' => null, 'endpoint' => 'https://api.resend.com/emails', 'timeout' => 30]

Methods

send()

public send(Message $message) : array<string|int, mixed>
Parameters
$message : Message
Tags
inheritDoc
Return values
array<string|int, mixed>

setHttpClient()

Set a custom HTTP client (useful for testing).

public setHttpClient(Client $client) : static
Parameters
$client : Client
Return values
static

assertSuccessResponse()

Assert a successful HTTP response or throw.

protected assertSuccessResponse(Response $response, string $provider, int ...$acceptedCodes) : void
Parameters
$response : Response

The HTTP response.

$provider : string

Provider name for error messages.

$acceptedCodes : int

HTTP status codes considered successful.

Tags
throws
RuntimeException

On non-success response.

buildResult()

Build the standard return value for send().

protected buildResult(Message $message) : array{headers: string, message: string}
Parameters
$message : Message
Return values
array{headers: string, message: string}

checkRecipient()

Validate that the message has at least one recipient.

protected checkRecipient(Message $message) : void
Parameters
$message : Message

The email message.

Tags
throws
RuntimeException

If no recipients are set.

formatAttachments()

Convert Message attachments to a provider-neutral format.

protected formatAttachments(Message $message) : array<int, array{name: string, contentType: string, content: string}>
Parameters
$message : Message
Return values
array<int, array{name: string, contentType: string, content: string}>

formatRecipients()

Convert Message address array to a flat list of recipient objects.

protected formatRecipients(array<string, string> $addresses) : array<int, array{email: string, name: string}>

CakePHP stores addresses as ['email@example.com' => 'Display Name'].

Parameters
$addresses : array<string, string>
Return values
array<int, array{email: string, name: string}>

getHttpClient()

Get or create the HTTP client instance.

protected getHttpClient() : Client
Return values
Client

getSender()

Get the sender address from a Message.

protected getSender(Message $message) : array{email: string, name: string}
Parameters
$message : Message

The email message.

Tags
throws
RuntimeException

If no sender is set.

Return values
array{email: string, name: string}

buildPayload()

Build the Resend API request payload.

private buildPayload(Message $message) : array<string|int, mixed>
Parameters
$message : Message
Return values
array<string|int, mixed>
On this page

Search results