Files
leadmail-sdk/README.md
netlas bf8aac48e6 Add Laravel 13 support
Bump illuminate/mail and illuminate/support to ^11.0|^12.0|^13.0, testbench to allow ^11.0, and update README requirements.
2026-06-08 21:14:09 +03:00

1.8 KiB

LeadMail SDK for Laravel

Laravel package for sending emails and verifying email addresses through the leadMail service.

Requirements

  • PHP 8.2+
  • Laravel 11, 12, or 13

Installation

composer require leadm/leadmail

Publish the config file:

php artisan vendor:publish --provider="LeadM\LeadMail\LeadMailServiceProvider"

Configuration

Add these to your .env:

LEADMAIL_URL=https://mail.leadmagnet.dev
LEADMAIL_TOKEN=lm_your_api_token_here

Optional settings:

LEADMAIL_TIMEOUT=30
LEADMAIL_VERIFY_SSL=true
LEADMAIL_AUTO_TENANT=true

Usage

Send Emails via Mail Driver

Set leadmail as your mail driver in .env:

MAIL_MAILER=leadmail

Then use Laravel's Mail facade as usual:

Mail::to('user@example.com')->send(new WelcomeMail());

Send Emails via API

LeadMail::sendEmail([
    'from' => ['email' => 'hello@yourdomain.com', 'name' => 'Your App'],
    'to' => [['email' => 'user@example.com', 'name' => 'User']],
    'subject' => 'Welcome!',
    'html_body' => '<h1>Welcome to our app</h1>',
]);

Verify Email Addresses

$result = LeadMail::verifyEmail('user@example.com');

if ($result['data']['valid']) {
    // Email is deliverable
}

Validation Rule

Use the leadmail_verify rule in your form requests:

public function rules(): array
{
    return [
        'email' => ['required', 'email', 'leadmail_verify'],
    ];
}

Get Allowed Sender Domains

$domains = LeadMail::getDomains();
// ['yourdomain.com', 'anotherdomain.com']

Multi-Tenancy

If your app uses stancl/tenancy, the SDK automatically includes the current tenant ID in API requests via the X-Tenant-Id header. Disable this with:

LEADMAIL_AUTO_TENANT=false

License

MIT