lettr/lettr-php Composer package and configuring the client for your application. If you haven’t already, start with the Introduction for a quick overview of what the SDK provides.
Requirements
- PHP 8.4 or higher
- Guzzle HTTP client 7.5+
Install the Package
Create a Client
Instantiate the Lettr client with your API key:client() method returns a configured instance ready to interact with the Lettr API. All subsequent method calls use this client for authentication and requests.
Store API Keys Securely
Never hardcode API keys in your source code. Store them in environment variables or configuration files that are excluded from version control:Available Services
The client provides access to all Lettr API resources through dedicated service objects:$lettr->emails() gives you access to:
- Sending emails (HTML, text, templates)
- Building complex emails with the fluent builder
- Attaching files and configuring tracking options
Verify Installation
Test that everything is configured correctly using the health check endpoints:health()->check() method verifies that the Lettr API is accessible and operational. It doesn’t require authentication, so it’s useful for monitoring and debugging connectivity issues.
The health()->authCheck() method validates your API key and returns your team ID. If no exception is thrown, your API key is valid and you’re ready to send emails.
Troubleshooting
API key not recognized
API key not recognized
Verify that your API key starts with
lttr_ and contains 64 hexadecimal characters after the prefix. Check for extra whitespace or newlines when loading from environment variables.Connection errors
Connection errors
If you see network or transport errors, check your firewall settings. The SDK needs to reach
https://app.lettr.com/api. If you’re behind a corporate proxy, you may need to configure Guzzle with proxy settings.Domain verification errors when sending
Domain verification errors when sending
The
from address must use a domain that is verified in your Lettr dashboard. 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.