lettermint/lettermint-php

Official Lettermint PHP SDK.

1.1.1 2025-06-28 14:05 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Integrate Lettermint in your PHP project.

Requirements

  • PHP 8.2 or higher
  • Composer

Installation

You can install the package via composer:

composer require lettermint/lettermint-php

Usage

Initialize the Lettermint client with your API token:

$lettermint = new Lettermint\Lettermint('your-api-token');

Sending Emails

The SDK provides a fluent interface for composing and sending emails:

$response = $lettermint->email
                       ->from('sender@example.com')
                       ->to('recipient@example.com')
                       ->subject('Hello from Lettermint!')
                       ->text('Hello! This is a test email.')
                       ->send();

The SDK supports various email features:

$lettermint->email
    ->from('John Doe <john@example.com>')
    ->to('recipient1@example.com', 'recipient2@example.com')
    ->cc('cc@example.com')
    ->bcc('bcc@example.com')
    ->replyTo('reply@example.com')
    ->subject('Hello world!')
    ->html('<h1>Hello!</h1>')
    ->text('Hello!')
    ->headers(['X-Custom-Header' => 'Value'])
    ->attach('document.pdf', base64_encode($fileContent))
    ->route('my-route-id')
    ->idempotencyKey('unique-request-id-123')
    ->send();

Idempotency

To ensure that duplicate requests are not processed, you can use an idempotency key:

$response = $lettermint->email
                       ->from('sender@example.com')
                       ->to('recipient@example.com')
                       ->subject('Hello from Lettermint!')
                       ->text('Hello! This is a test email.')
                       ->idempotencyKey('unique-request-id-123')
                       ->send();

The idempotency key should be a unique string that you generate for each unique email you want to send. If you make the same request with the same idempotency key, the API will return the same response without sending a duplicate email.

For more information, refer to the documentation.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.