Skip to main content
This page provides a comprehensive reference for all configuration options available in the Lettermint Laravel package.

Package Configuration

The package configuration is located in config/lettermint.php. Publish it using:
php artisan vendor:publish --tag=lettermint-config

API Token

token
string
required
Your Lettermint API token. Every Lettermint project has a unique API token that can be found in your project settings.Environment Variable: LETTERMINT_TOKEN
'token' => env('LETTERMINT_TOKEN'),
Alternatively, you can configure the token in config/services.php:
'services' => [
    'lettermint' => [
        'token' => env('LETTERMINT_TOKEN'),
    ],
],

Webhook Configuration

All webhook-related settings are nested under the webhooks key.
webhooks.secret
string
required
The signing secret used to verify incoming webhook requests from Lettermint. This ensures that the webhook payload is authentic and hasn’t been tampered with.Environment Variable: LETTERMINT_WEBHOOK_SECRETDefault: null
'secret' => env('LETTERMINT_WEBHOOK_SECRET'),
Find your webhook signing secret in your Lettermint project settings under the Webhooks section.
webhooks.prefix
string
The route prefix for the webhook endpoint. The full webhook URL will be constructed as {your-app-url}/{prefix}/webhook.Environment Variable: LETTERMINT_WEBHOOK_PREFIXDefault: lettermint
'prefix' => env('LETTERMINT_WEBHOOK_PREFIX', 'lettermint'),
Example URLs:
  • Default: https://yourapp.com/lettermint/webhook
  • Custom prefix api/events: https://yourapp.com/api/events/webhook
webhooks.tolerance
integer
The maximum allowed time difference (in seconds) between the webhook timestamp and the current server time. This helps prevent replay attacks.Environment Variable: LETTERMINT_WEBHOOK_TOLERANCEDefault: 300 (5 minutes)
'tolerance' => env('LETTERMINT_WEBHOOK_TOLERANCE', 300),
If the timestamp difference exceeds this value, the webhook request will be rejected.

Mail Transport Configuration

Configure the Lettermint mail transport in config/mail.php to send emails using Laravel’s Mail facade.

Basic Setup

'mailers' => [
    'lettermint' => [
        'transport' => 'lettermint',
    ],
],

Transport Options

route_id
string
The Lettermint route ID to use for sending emails through this mailer. When specified, all emails sent through this mailer will use the specified route.
'mailers' => [
    'lettermint' => [
        'transport' => 'lettermint',
        'route_id' => 'route_abc123',
    ],
],
This is useful when you have multiple sending routes configured in Lettermint and want to assign specific mailers to specific routes.
idempotency
boolean
Enable automatic idempotency key generation for emails sent through this mailer. When enabled, the package automatically generates a stable idempotency key based on email content.Default: false
'mailers' => [
    'lettermint' => [
        'transport' => 'lettermint',
        'idempotency' => true,
    ],
],
The idempotency key is generated using a SHA256 hash of:
  • Email subject
  • Recipients (to, cc, bcc)
  • Email body (HTML or text)
  • Sender address
  • Timestamp (if window is less than 24 hours)
This ensures that retrying the same email (e.g., from a failed queue job) won’t result in duplicate sends.
Individual emails can override this by setting a custom Idempotency-Key header, which takes precedence over automatic generation.
idempotency_window
integer
The time window (in seconds) for automatic idempotency key generation. This option is only used when idempotency is enabled.Default: 86400 (24 hours)
'mailers' => [
    'lettermint' => [
        'transport' => 'lettermint',
        'idempotency' => true,
        'idempotency_window' => 3600, // 1 hour
    ],
],
How it works:
  • 24 hours (default): The idempotency key remains the same for the same email content indefinitely, matching Lettermint’s API retention period. This provides permanent deduplication.
  • Less than 24 hours: The current timestamp (rounded to the window) is included in the key generation. This allows the same email to be sent again after the window expires.
Example use cases:
WindowUse Case
86400 (24h)Prevent duplicate sends permanently (useful for transactional emails)
3600 (1h)Allow resending the same email after 1 hour (useful for notifications)
300 (5m)Short-term retry protection for queue failures

Configuration Examples

Basic Configuration

config/lettermint.php:
return [
    'token' => env('LETTERMINT_TOKEN'),
    'webhooks' => [
        'secret' => env('LETTERMINT_WEBHOOK_SECRET'),
        'prefix' => 'lettermint',
        'tolerance' => 300,
    ],
];
.env:
LETTERMINT_TOKEN=your_api_token_here
LETTERMINT_WEBHOOK_SECRET=your_webhook_secret_here

Multiple Mailers with Different Routes

config/mail.php:
'mailers' => [
    // Transactional emails with idempotency
    'transactional' => [
        'transport' => 'lettermint',
        'route_id' => 'route_transactional',
        'idempotency' => true,
        'idempotency_window' => 86400, // 24 hours
    ],
    
    // Marketing emails without idempotency
    'marketing' => [
        'transport' => 'lettermint',
        'route_id' => 'route_marketing',
        'idempotency' => false,
    ],
    
    // Notification emails with short retry window
    'notifications' => [
        'transport' => 'lettermint',
        'route_id' => 'route_notifications',
        'idempotency' => true,
        'idempotency_window' => 3600, // 1 hour
    ],
],

Custom Webhook Endpoint

config/lettermint.php:
return [
    'token' => env('LETTERMINT_TOKEN'),
    'webhooks' => [
        'secret' => env('LETTERMINT_WEBHOOK_SECRET'),
        'prefix' => 'api/webhooks/lettermint',
        'tolerance' => 600, // 10 minutes
    ],
];
This configures the webhook endpoint at https://yourapp.com/api/webhooks/lettermint/webhook.

Build docs developers (and LLMs) love