Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lettr.com/llms.txt

Use this file to discover all available pages before exploring further.

Before you can send email, the sending domain must be verified in Lettr. The $lettr->domains() service lets you manage domains programmatically — useful for multi-tenant apps that onboard customer domains, or for automating DNS verification checks. For the concepts behind domain setup (SPF, DKIM, DMARC, tracking domains), see Sending Domains.

List Domains

$domains = $lettr->domains()->list();

foreach ($domains as $domain) {
    echo $domain->domain;                    // example.com
    echo $domain->status->value;             // 'pending', 'approved'
    echo $domain->canSend;                   // true/false
    echo $domain->dkimStatus?->value;        // 'valid', 'invalid', etc.
    echo $domain->cnameStatus?->value;       // 'valid', 'invalid', etc.
}

API Reference

GET /domains

Add a Domain

use Lettr\ValueObjects\DomainName;

$result = $lettr->domains()->create('example.com');
// or pass a DomainName value object
$result = $lettr->domains()->create(new DomainName('example.com'));

echo $result->domain;        // example.com
echo $result->status->value; // 'pending'
echo $result->statusLabel;   // "Pending Review"

// DKIM configuration to publish in DNS
if ($result->dkim !== null) {
    echo $result->dkim->selector;      // DKIM selector (e.g. "scph0226")
    echo $result->dkim->publicKey;     // DKIM public key
    echo $result->dkim->headers;       // Signed headers (e.g. "from:to:subject:date")
    echo $result->dkim->signingDomain; // Signing domain
}
Adding a domain returns the DNS records you need to publish. Once published, call verify() to check them.

API Reference

POST /domains

Get Domain Details

$domain = $lettr->domains()->get('example.com');

echo $domain->domain;
echo $domain->status->value;
echo $domain->canSend;
echo $domain->dkimStatus?->label();   // DnsStatus enum
echo $domain->cnameStatus?->label();
echo $domain->dmarcStatus?->label();
echo $domain->spfStatus?->label();
echo $domain->trackingDomain;
echo $domain->createdAt;

// DKIM record helpers
if ($domain->dkim !== null) {
    echo $domain->dkim->recordName('example.com'); // Full DNS record name
    echo $domain->dkim->recordValue();             // Full DNS record value
}

API Reference

GET /domains/

Verify Domain DNS

After publishing the DNS records, trigger a verification check:
$verification = $lettr->domains()->verify('example.com');

if ($verification->isFullyVerified()) {
    echo "Domain is ready to send!";
} else {
    // Individual record statuses
    echo $verification->dkimStatus->label();   // "Valid", "Invalid", "Missing", etc.
    echo $verification->cnameStatus->label();
    echo $verification->dmarcStatus->label();
    echo $verification->spfStatus->label();

    // Specific DNS record errors
    if ($verification->hasErrors()) {
        foreach ($verification->errors() as $type => $error) {
            echo "$type: $error";
        }
    }
}
DNS changes can take time to propagate. If verification fails immediately after publishing records, wait a few minutes and try again. See Domain Verification troubleshooting for common issues.

API Reference

POST /domains//verify

Delete a Domain

$lettr->domains()->delete('example.com');
Deleting a domain stops all sending from that domain immediately. Emails sent from a deleted domain will fail with a validation error.

API Reference

DELETE /domains/

What’s Next

Sending Domains

DNS setup: SPF, DKIM, DMARC

Webhooks

Receive delivery and engagement events