Skip to main content

Documentation Index

Fetch the complete documentation index at: https://jetemail.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

PHP SDK

The jetemail/jetemail-php package is the official PHP SDK for JetEmail transactional email (MIT license, PHP 8.1+). Create a transactional API key in the dashboard: OutboundKeys → Add API key. Use that key with the SDK.
For Laravel projects, use the dedicated Laravel SDK which includes Mail driver integration and webhook support.

Installation

composer require jetemail/jetemail-php
Package on Packagist: jetemail/jetemail-php.

Quick start

use JetEmail\JetEmail;
use JetEmail\SendEmailOptions;

$client = new JetEmail('your-transactional-api-key');

$result = $client->email->send(new SendEmailOptions(
    from: 'Your App <hello@yourdomain.com>',
    to: 'user@example.com',
    subject: 'Welcome!',
    html: '<h1>Welcome!</h1>',
));
Use a from address on a verified domain (see Getting started).

Constructor

// API key string
$client = new JetEmail('your-transactional-api-key');

// Or with options
$client = new JetEmail(
    apiKey: 'your-transactional-api-key',
    baseUrl: 'https://api.jetemail.com', // optional
);

$client->email->send(options)

Send a single email.
FieldRequiredDescription
fromSender, e.g. "Name <email@domain.com>"
toRecipient(s), string or array (max 50)
subjectSubject line
html*HTML body (need html and/or text)
text*Plain text (need html and/or text)
cc, bcc, replyToRecipients (max 50 each)
headersCustom headers array
attachmentsAttachments (max 40MB total)
Response shape: ['id' => string, 'response' => string].

$client->batch->send(emails)

Send up to 100 emails in one request. Returns summary (total, successful, failed) and results per message.
$result = $client->batch->send([
    new SendEmailOptions(
        from: 'you@example.com',
        to: 'alice@example.com',
        subject: 'Hello Alice',
        html: '<p>Hi Alice!</p>',
    ),
    new SendEmailOptions(
        from: 'you@example.com',
        to: 'bob@example.com',
        subject: 'Hello Bob',
        html: '<p>Hi Bob!</p>',
    ),
]);

Attachments

use JetEmail\Attachment;

$result = $client->email->send(new SendEmailOptions(
    from: 'you@example.com',
    to: 'recipient@example.com',
    subject: 'Invoice',
    html: '<p>Please find your invoice attached.</p>',
    attachments: [
        Attachment::fromPath('/path/to/invoice.pdf'),
        Attachment::fromContent('Hello World', 'hello.txt'),
    ],
));

Error handling

use JetEmail\JetEmailException;

try {
    $client->email->send(new SendEmailOptions(...));
} catch (JetEmailException $e) {
    echo $e->getMessage();
    echo $e->statusCode;
    echo $e->response;
}
Common status codes: 400 invalid request, 401 bad/missing API key, 500 server error.
For additional examples and the full option list, see the Packagist package page. REST details: API reference.