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, or 12.x
Install the Package
Configuration
Option 1: Interactive Setup (Recommended)
Run the init command for guided configuration:Option 2: Manual Setup
Publish the config file
config/lettr.php with customizable options. See Configuration Options below for a full reference of available settings.Add the Lettr mailer
Add the Lettr mailer to This registers Lettr as an available mailer in Laravel’s mail system. You can use it alongside other mailers (e.g.,
config/mail.php:config/mail.php
smtp, log, ses) and choose per-email which one to use.Configure sender address
Set your default sender address in
.env. The address must use a verified sending domain:Configuration Options
Theconfig/lettr.php file contains these options:
config/lettr.php
| Option | Description |
|---|---|
api_key | Your Lettr API key. Always set via the LETTR_API_KEY environment variable — never hardcode it. |
default_project_id | The default project to use when pulling/pushing templates. Can be overridden per-request. |
templates.html_path | Where lettr:pull --as-html saves raw HTML template files. |
templates.blade_path | Where lettr:pull saves Blade template files. |
templates.mailable_path | Where lettr:pull --with-mailables generates Mailable classes. |
templates.mailable_namespace | PHP namespace for generated Mailable classes. |
templates.dto_path | Where lettr:generate-dtos creates DTO classes. |
templates.dto_namespace | PHP namespace for generated DTOs. |
templates.enum_path | Where lettr:generate-enum creates the template enum. |
templates.enum_namespace | PHP namespace for the generated enum. |
templates.enum_class | Class name for the generated template enum. |
Verify Installation
Run the check command to verify your installation:Troubleshooting
API key not recognized
API key not recognized
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.Class not found errors
Class not found errors
Run
composer dump-autoload to regenerate the autoloader. If you’re using Laravel’s config cache, run php artisan config:clear as well.Domain verification errors when sending
Domain verification errors when sending
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.Emails not arriving
Emails not arriving
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.