1. Installation

Install the SDK via Composer:

composer require lettermint/lettermint-php

2. Send your first email

Initialize the client with your API token:

<?php

require_once 'vendor/autoload.php';

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

Send your first email:

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

echo "Email sent with ID: " . $response->id;

3. Email Features

Basic Email

Send a simple text or HTML email:

$lettermint->email
    ->from('John Doe <john@yourdomain.com>')
    ->to('recipient@example.com')
    ->subject('Your acount is ready!')
    ->html('<h1>Welcome!</h1><p>Thanks for signing up.</p>')
    ->text('Welcome! Thanks for signing up.')
    ->send();

Multiple Recipients

Send to multiple recipients using CC and BCC:

$lettermint->email
    ->from('John Doe <john@yourdomain.com>')
    ->to('user1@example.com', 'user2@example.com')
    ->cc('manager@yourdomain.com')
    ->bcc('archive@yourdomain.com')
    ->subject('Monthly Newsletter')
    ->html('<h1>This Month\'s Updates</h1>')
    ->send();

Custom Headers and Reply-To

Add custom headers and set reply-to addresses:

$lettermint->email
    ->from('support@yourdomain.com')
    ->to('customer@example.com')
    ->replyTo('help@yourdomain.com')
    ->subject('Support Ticket #12345')
    ->headers([
        'X-Priority' => '1',
        'X-Ticket-ID' => '12345'
    ])
    ->html('<p>Your support ticket has been updated.</p>')
    ->send();

File Attachments

Attach files to your emails:

// Read file content
$fileContent = file_get_contents('/path/to/document.pdf');

$lettermint->email
    ->from('invoices@yourdomain.com')
    ->to('customer@example.com')
    ->subject('Your Invoice')
    ->html('<p>Please find your invoice attached.</p>')
    ->attach('invoice.pdf', base64_encode($fileContent))
    ->send();

4. Response

$response = $lettermint->email
    ->from('John Doe <john@yourdomain.com>')
    ->to('recipient@example.com')
    ->subject('Test')
    ->text('Hello!')
    ->send();

echo $response->message_id; // Email ID
echo $response->status;     // Current status

GitHub Repository

Find the complete source code, report issues, or contribute on GitHub.