> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lettr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> Send transactional emails from any PHP app with the type-safe lettr/lettr-php SDK, featuring a fluent builder and typed error handling.

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](https://cursor.com/link/prompt?text=Help%20me%20add%20a%20Lettr%20sending%20example%20for%20PHP%20using%20lettr%2Flettr-php%2C%20or%20migrate%20my%20current%20PHP%20sending%20solution%20to%20Lettr%20using%20these%20docs%3A%20https%3A%2F%2Fdocs.lettr.com%2Fquickstart%2Fphp%2Fintroduction)

## 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)

<Note>
  If you're using Laravel, consider using the framework-specific SDK instead for deeper integration: [Laravel SDK](/quickstart/laravel/introduction)
</Note>

## Prerequisites

Before you begin, make sure you have:

<CardGroup cols={2}>
  <Card title="API Key" icon="key" href="https://app.lettr.com/api-keys">
    Create an API key in the Lettr dashboard
  </Card>

  <Card title="Verified Domain" icon="globe" href="/learn/domains/sending-domains">
    Add and verify your sending domain
  </Card>
</CardGroup>

You'll also need:

* **PHP 8.4+** and **Composer** installed
* A verified sending domain in your [Lettr dashboard](https://app.lettr.com/domains)

## Quick Setup

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

<Steps>
  <Step title="Install the package">
    ```bash theme={null}
    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.
  </Step>

  <Step title="Create a client">
    ```php theme={null}
    use Lettr\Lettr;

    $lettr = Lettr::client('your-api-key');
    ```

    <Tip>
      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.
    </Tip>
  </Step>

  <Step title="Send your first email">
    ```php theme={null}
    $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).
  </Step>
</Steps>

<Warning>
  The sender domain must be verified in your [Lettr dashboard](https://app.lettr.com/domains) before you can send emails. If you try to send from an unverified domain, the API returns a `422` validation error. See [Sending Domains](/learn/domains/sending-domains) for setup instructions.
</Warning>

## Verify Your API Key

Test that your API key is valid before sending emails:

```php theme={null}
$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.

<Tip>
  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.
</Tip>

## Using a Framework?

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

<CardGroup cols={2}>
  <Card title="Laravel" icon="laravel" href="/quickstart/laravel/introduction">
    Mail facade integration, Mailables, and code generation
  </Card>

  <Card title="SMTP" icon="server" href="/quickstart/smtp/introduction">
    Use SMTP instead of the HTTP API
  </Card>

  <Card title="WordPress" icon="wordpress" href="/integrations/wordpress">
    Send all WordPress emails through Lettr
  </Card>
</CardGroup>

## Section Overview

This quickstart is organized into focused pages:

| Page                                             | What You'll Learn                                                                      |
| ------------------------------------------------ | -------------------------------------------------------------------------------------- |
| [Installation](/quickstart/php/installation)     | Package requirements, client setup, and verifying your installation                    |
| [Sending Emails](/quickstart/php/sending-emails) | All sending methods — HTML, text, templates, attachments, tracking, and error handling |
| [Templates](/quickstart/php/templates)           | Managing Lettr templates, versioning, and retrieving merge tags                        |
| [Domains](/quickstart/php/domains)               | Add, verify, and manage sending domains                                                |
| [Webhooks](/quickstart/php/webhooks)             | Create and manage webhook endpoints for delivery and engagement events                 |
| [Audience](/quickstart/php/audience)             | Manage lists, contacts, topics, properties, and segments                               |
| [Campaigns](/quickstart/php/campaigns)           | List, inspect, send, and schedule campaigns                                            |

## What's Next

<CardGroup cols={2}>
  <Card title="Installation" icon="download" href="/quickstart/php/installation">
    Detailed setup and client configuration
  </Card>

  <Card title="Sending Emails" icon="paper-plane" href="/quickstart/php/sending-emails">
    Learn all the ways to send emails
  </Card>

  <Card title="Templates" icon="file-code" href="/quickstart/php/templates">
    Work with Lettr-managed templates
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Complete API documentation
  </Card>
</CardGroup>
