Skip to main content
Send transactional emails from any PHP application using the official Lettr PHP SDK. The SDK provides a clean, type-safe interface for the Lettr API without requiring a specific framework. The lettr/lettr-php package gives you a fluent interface for building and sending emails, managing templates, and tracking delivery — all with full IDE autocompletion and compile-time safety. Using Cursor? Jump straight in using this prompt

Why Use the PHP SDK?

Rather than making raw HTTP requests, the SDK provides:
  • Type-safe API client — Full IDE autocompletion and type hints for all methods
  • Fluent email builder — Chainable methods for constructing complex emails
  • Template support — Send Lettr-managed templates with merge tags and versioning
  • Error handling — Typed exceptions for different API errors (validation, auth, not found)
  • Zero dependencies — Only requires Guzzle HTTP client (which most PHP projects already use)
If you’re using Laravel, consider using the framework-specific SDK instead for deeper integration: Laravel SDK

Prerequisites

Before you begin, make sure you have: You’ll also need:
  • PHP 8.4+ and Composer installed
  • A verified sending domain in your Lettr dashboard

Quick Setup

The fastest way to get started is a three-step install, configure, and send process.
1

Install the package

composer require lettr/lettr-php
The package requires PHP 8.4+ and Guzzle 7.5+. Composer will install Guzzle automatically if it’s not already in your project.
2

Create a client

use Lettr\Lettr;

$lettr = Lettr::client('your-api-key');
Store your API key in environment variables or a config file, never hardcode it. API keys use the lttr_ prefix followed by 64 hexadecimal characters.
3

Send your first email

$response = $lettr->emails()->send(
    $lettr->emails()->create()
        ->from('sender@yourdomain.com', 'Your App')
        ->to(['recipient@example.com'])
        ->subject('Hello from Lettr')
        ->html('<h1>Hello!</h1><p>This is a test email.</p>')
);

echo $response->requestId; // Request ID for tracking
echo $response->accepted;  // Number of accepted recipients
The builder pattern lets you chain methods to construct your email. All emails require from, to, subject, and at least one content type (html, text, or a template).
The sender domain must be verified in your Lettr dashboard before you can send emails. If you try to send from an unverified domain, the API returns a 422 validation error. See Sending Domains for setup instructions.

Verify Your API Key

Test that your API key is valid before sending emails:
$auth = $lettr->health()->authCheck();

echo $auth->teamId; // Your team ID
If no exception is thrown, you’re authenticated and ready to send emails. This check verifies that your API key is correctly formatted, active, and has permission to access your team’s resources.
During development, use the health check endpoint to catch configuration issues early. It’s a quick way to verify your setup before attempting to send emails.

Using a Framework?

If you’re working within a specific PHP framework, these integrations provide deeper integration:

Section Overview

This quickstart is organized into three focused pages:
PageWhat You’ll Learn
InstallationPackage requirements, client setup, and verifying your installation
Sending EmailsAll sending methods — HTML, text, templates, attachments, tracking, and error handling
TemplatesManaging Lettr templates, versioning, and retrieving merge tags

What’s Next