Skip to main content
This page covers installing the lettr/lettr-laravel Composer package and configuring it to send emails through Lettr. If you haven’t already, start with the Introduction for a quick overview of what the SDK provides.

Requirements

  • PHP 8.4 or higher
  • Laravel 10.x, 11.x, 12.x, or 13.x

Install the Package

The package uses Laravel’s auto-discovery, so the service provider registers automatically. No manual provider registration is needed.

Configuration

Run the init command for guided configuration:
This handles all the steps below automatically. The command walks you through each setting interactively, so you don’t need to edit config files by hand. If you want full control over each step, use the manual setup below.

Option 2: Manual Setup

1

Add your API key

Add your Lettr API key to .env:
Get your API key from the Lettr dashboard. API keys use the lttr_ prefix followed by 64 hexadecimal characters. See API Keys for details on creating and managing keys.
2

Publish the config file

This creates config/lettr.php with customizable options. See Configuration Options below for a full reference of available settings.
3

Add the Lettr mailer

Add the Lettr mailer to config/mail.php:
config/mail.php
This registers Lettr as an available mailer in Laravel’s mail system. You can use it alongside other mailers (e.g., smtp, log, ses) and choose per-email which one to use.
4

Configure sender address

Set your default sender address in .env. The address must use a verified sending domain:
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 will return a 422 error. See Sending Domains for setup instructions.
5

Set as default mailer (optional)

To use Lettr as your default mailer, update .env:
Or keep your current mailer and use Lettr explicitly when needed:
During development, you may want to keep MAIL_MAILER=log to avoid sending real emails. Switch to lettr in staging and production.

Configuration Options

The config/lettr.php file contains these options:
config/lettr.php

Verify Installation

Run the check command to verify your installation:
This validates your API key and configuration. If everything is set up correctly, you’ll see a success message.

Troubleshooting

Make sure your .env file contains LETTR_API_KEY with the lttr_ prefix. Run php artisan config:clear to clear any cached configuration, then try again.
Run composer dump-autoload to regenerate the autoloader. If you’re using Laravel’s config cache, run php artisan config:clear as well.
The from address must use a domain that is verified in your Lettr dashboard. Check that your MAIL_FROM_ADDRESS in .env matches a verified sending domain. See Domain Verification for common issues.
Check your Lettr logs to see if the API accepted the request. If the email was accepted but not delivered, see Delivery Issues for diagnosis steps.

What’s Next

Sending Emails

Learn the different ways to send emails through Lettr

Templates

Work with Lettr-managed templates and merge tags