Download the PHP package lettr/lettr-php without Composer

On this page you can find all versions of the php package lettr/lettr-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lettr-php

Lettr PHP SDK

CI Latest Version on Packagist Total Downloads PHP Version License

Official PHP SDK for the Lettr email API.

Requirements

Installation

Quick Start

Sending Emails

Using the Email Builder (Recommended)

The fluent builder provides a clean API for constructing emails:

Using SendEmailData DTO

For programmatic email construction:

Quick Send Methods

For simple use cases:

The from parameter accepts a plain email string or an EmailAddress value object when you need a sender name:

Attachments

Templates with Substitution Data

Custom Headers

You can add custom email headers (e.g. X-Custom-ID, X-Entity-Ref-ID) to your emails. Maximum 10 headers, each value up to 998 characters:

Note: Some standard headers (e.g. List-Unsubscribe for non-transactional emails) may be overwritten by the email delivery provider. Use custom headers for application-specific headers like X-Custom-ID.

Email Options

Emails are sent as transactional by default, matching the API's default behavior. For marketing emails, explicitly set transactional(false):

Idempotent Sends

Attach an Idempotency-Key and a retry of the same send returns the original result instead of delivering a second email:

You choose the key; the SDK never generates one. It only works if the same key is used on both attempts, and the SDK does not retry — one send() is one HTTP request — so the retry is yours. Use something stable for one logical send: an order id, a job id, anything you can regenerate. A fresh value per attempt protects nothing.

If you have no natural id, IdempotencyKey::forPayload($data) derives one from the payload. Note the trade: two deliberately identical sends within 24 hours then collapse into one.

Handle the two conflicts differently — one is retryable and the other is not:

Both extend ConflictException, so existing handlers keep catching them.

Format 1–255 characters, [A-Za-z0-9._-] — validated locally before the request
Retention 24 hours
Scope Per team and API key — the same string through a different API key is a different key

Scheduled Emails

Schedule an email for any time between 5 minutes and 30 days out. Lettr holds it until then, so it can be listed, read back and cancelled right up to the moment it is sent.

The two ids are not interchangeable. requestId identifies the scheduled email for its whole life. transmissionId is the sending provider's id: it stays null until the email goes out, and it is the value that appears on your webhook events, so use that one to correlate them.

States are Scheduled, Sending, Sent, Cancelled and Failed. Cancelling is only possible while Scheduled; once it is being sent or has been sent, cancelScheduled() throws a ConflictException. A Failed email carries a failureReason.

Once an email has been sent, events fills in from its delivery events — empty before that, and for a few minutes afterwards while they are indexed.

Marketing Emails & Unsubscribe

When sending marketing emails (transactional(false)), the email provider automatically adds List-Unsubscribe and List-Unsubscribe-Post headers for compliance. To allow recipients to unsubscribe from your marketing emails:

  1. Add an unsubscribe link in your HTML using the data-msys-unsubscribe attribute:

The href must use https:// — when clicked, the user will be redirected to your URL. The actual unsubscribe handling should be done server-side by listening for webhook events.

  1. Listen for unsubscribe events via webhooks — subscribe to link_unsubscribe and list_unsubscribe event types to process unsubscribes in your application.

Health Check

Value Objects

The SDK uses value objects for type safety and validation:

Error Handling

Rate Limits

The API enforces a rate limit of 3 requests per second per team, shared across all API keys. Rate limit headers are included in every authenticated API response:

Header Description
X-Ratelimit-Limit Maximum requests per second
X-Ratelimit-Remaining Remaining requests in current window
X-Ratelimit-Reset Unix timestamp when the limit resets
Retry-After Seconds to wait (only on 429 responses)

You can read rate limit info after any API call:

Sending Quotas

Free tier teams have monthly and daily sending limits. Quota headers are included in send email responses:

Header Description
X-Monthly-Limit Total monthly email limit
X-Monthly-Remaining Remaining emails this month
X-Monthly-Reset Unix timestamp when monthly quota resets
X-Daily-Limit Total daily email limit
X-Daily-Remaining Remaining emails today
X-Daily-Reset Unix timestamp when daily quota resets

Quota information is available on successful responses via $response->quota and on quota exceeded errors via the QuotaExceededException.

Documentation

Full guides, every method, and complete request/response details live in the docs:

📚 docs.lettr.com/quickstart/php

Topic Guide
Install & client setup Installation
Sending — HTML, text, templates, attachments, tracking, errors Sending Emails
Managing templates & merge tags Templates
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

Development

Install Dependencies

Code Style

This project uses Laravel Pint for code style:

Static Analysis

This project uses PHPStan at level 8:

Testing

This project uses Pest for testing:

Contributing

Please see CONTRIBUTING for details.

License

MIT License. See LICENSE for details.


All versions of lettr-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
guzzlehttp/guzzle Version ^7.5 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lettr/lettr-php contains the following files

Loading the files please wait ...