Download the PHP package lettr/lettr-laravel without Composer
On this page you can find all versions of the php package lettr/lettr-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lettr-laravel
Lettr for Laravel
Official Laravel integration for the Lettr email API.
Requirements
- PHP 8.4+
- Laravel 10.x, 11.x, 12.x, or 13.x
Installation
Publish the configuration file:
Getting Started
The easiest way to set up Lettr in your Laravel application is using the interactive init command:
This command will guide you through:
- API Key Configuration - Automatically adds your Lettr API key to
.env - Mailer Setup - Configures the Lettr mailer in
config/mail.php - Template Download - Optionally pulls your email templates as Blade files
- Code Generation - Generates type-safe DTOs, Mailables, and template enums
- Domain Verification - Checks your sending domain is properly configured
Tip: If you already have a verified sending domain in your Lettr account, the init command will automatically configure your
MAIL_FROM_ADDRESSto match it.
After running lettr:init, you're ready to send emails:
Manual Setup
If you prefer to configure manually, add your Lettr API key to your .env file:
Sending Domain
To send emails through Lettr, you must have a verified sending domain in your Lettr account. Your MAIL_FROM_ADDRESS (or any "from" address you use) must match a verified domain.
For example, if you've verified example.com in Lettr:
Emails sent from addresses on unverified domains will be rejected.
Quick Start
Using Laravel Mail (Recommended)
Add the Lettr mailer to your config/mail.php:
Set as default in .env:
Send emails using Laravel's Mail facade:
Using the Lettr Facade Directly
Laravel Mail Integration
With Mailable Classes
With Raw Content
With Views
Multiple Mail Drivers
Use Lettr for specific emails while keeping another default:
Using Lettr Templates with Mailables
Instead of using Blade views, you can send emails using Lettr templates directly. Extend the LettrMailable class:
Then send it like any other Mailable:
LettrMailable Methods
| Method | Description |
|---|---|
template($slug, $version) |
Set template slug with optional version |
templateVersion($version) |
Set template version separately |
substitutionData($data) |
Set substitution variables for the template |
customHeaders($headers) |
Set custom email headers |
scheduledAt($when) |
Schedule delivery for a future DateTimeInterface (or ISO-8601 string) |
Example: Order Confirmation
Inline Template Sending
For quick template sending without creating a Mailable class, use the Mail::lettr() method:
Note: When no subject is provided, the template's own subject is used. Pass a
subjectonly if you want to override it.
Custom From Address
By default, emails are sent from the address configured in MAIL_FROM_ADDRESS. To send from a different address (e.g. a marketing domain), use from():
For Mailable classes, you can also set the from address in the envelope() method:
Note: The from address must belong to a verified sending domain in your Lettr account.
Custom Headers
You can pass custom headers with your emails. These are forwarded directly to the Lettr API.
For Mailable classes, use the customHeaders() method:
Error Handling
Configuration
The published config/lettr.php file contains:
The templates block configures where lettr:pull, lettr:generate-dtos, and lettr:generate-enum commands save generated files.
The package also supports config('services.lettr.key') as a fallback for the API key.
Documentation
Full guides, every facade method, and complete request/response details live in the docs:
📚 docs.lettr.com/quickstart/laravel
| Topic | Guide |
|---|---|
| Install, config, and verify | Installation |
| Mail facade, Lettr facade, Mailables, scheduling, testing | Sending Emails |
| Lettr templates, versioning, pull/push | Templates |
| Generated enums, DTOs, and Mailables | Type Safety |
| Add, verify, and manage sending domains | Domains |
| Webhook endpoints for delivery & engagement events | Webhooks |
| Lists, contacts, topics, properties, segments | Audience |
| List, send, and schedule campaigns | Campaigns |
| Endpoint reference (params & schemas) | API Reference |
CLI Commands
lettr:check
Verify that your Lettr integration is correctly configured:
Checks mailer registration, API key validity, and sending domain verification. Returns exit code 0 if all checks pass.
lettr:pull
Download email templates from your Lettr account as Blade files:
| Option | Description |
|---|---|
--template= |
Pull only a specific template by slug |
--as-html |
Save as raw HTML instead of Blade |
--with-mailables |
Also generate Mailable and DTO classes |
--skip-templates |
Skip downloading templates, only generate DTOs and Mailables |
--dry-run |
Preview what would be downloaded |
lettr:generate-enum
Generate a PHP enum from your Lettr template slugs for type-safe template references:
Generates an enum like:
lettr:generate-dtos
Generate type-safe DTO classes from template merge tags:
Generated DTOs implement Arrayable and can be passed directly to sendTemplate():
Development
Install Dependencies
Code Style
Static Analysis
Testing
Contributing
Please see CONTRIBUTING for details.
License
MIT License. See LICENSE for details.
All versions of lettr-laravel with dependencies
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
lettr/lettr-php Version ^2.4.0
symfony/mailer Version ^6.2|^7.0|^8.0