Skip to main content

Install

composer require sendkit/sendkit-laravel

Configure

Add your API key to your .env file:
.env
SENDKIT_API_KEY=sk_your_api_key

Send email

Using the Laravel Mail driver

SendKit integrates with Laravel’s built-in Mail system. Just set the mailer in your .env:
.env
MAIL_MAILER=sendkit
That’s it. Send emails using Laravel’s standard Mail facade as usual:
use App\Mail\WelcomeEmail;
use Illuminate\Support\Facades\Mail;

Mail::to('recipient@example.com')->send(new WelcomeEmail());

Using the SendKit facade

If you need more control, you can use the SendKit facade directly:
use SendKit\Laravel\Facades\SendKit;

$response = SendKit::emails()->send([
    'from' => 'Your Name <you@yourdomain.com>',
    'to' => 'recipient@example.com',
    'subject' => 'Hello from SendKit',
    'html' => '<h1>Welcome!</h1><p>Your first email with SendKit.</p>',
]);

echo $response['id'];

Validate email

Validate an email address before sending. Each validation costs credits.
use SendKit\Laravel\Facades\SendKit;

$result = SendKit::validateEmail('recipient@example.com');

if ($result['should_block']) {
    // Email should not be used
    echo $result['block_reason'];
}

echo $result['is_valid'];           // "HIGH" or "LOW"
echo $result['evaluations'];        // detailed checks
The evaluations array contains:
KeyDescription
has_valid_syntaxWhether the email has valid syntax
has_valid_dnsWhether the domain has valid DNS records
mailbox_existsWhether the mailbox exists
is_role_addressWhether it’s a role address (e.g. info@, admin@)
is_disposableWhether it’s a disposable email
is_random_inputWhether it appears to be random input

Webhooks

The package automatically registers a POST /webhook/sendkit route in your application — no extra setup needed. When SendKit sends a webhook to this endpoint, the package verifies the signature and dispatches a Laravel event you can listen to.

Add your webhook secret

To verify that incoming webhooks are actually from SendKit, add your webhook secret to .env:
.env
SENDKIT_WEBHOOK_SECRET=your-webhook-secret
You can find your webhook secret in the SendKit dashboard. When a secret is configured, every incoming request is verified using HMAC-SHA256. If the signature doesn’t match, the request is rejected with a 403 response.
If no secret is configured, signature verification is skipped. We strongly recommend always setting a secret in production.

Customizing the webhook path

By default the webhook listens at /webhook/sendkit. You can change this with an environment variable:
.env
SENDKIT_WEBHOOK_PATH=api/webhooks/sendkit
This will register the route at POST /api/webhooks/sendkit instead. Make sure to update the webhook URL in your SendKit dashboard to match.

Listening for events

When a webhook is received, the package dispatches a Laravel event based on the event type. You can listen for these events anywhere you normally would — in a listener, a service provider, or an EventServiceProvider:
use SendKit\Laravel\Events\EmailDelivered;
use Illuminate\Support\Facades\Event;

Event::listen(EmailDelivered::class, function ($event) {
    $emailId = $event->payload['email_id'];

    // Handle the delivered email
});
Every event has a payload property with the webhook data sent by SendKit.

Available events

Event classWebhook typeTriggered when
EmailSentemail.sentEmail accepted for delivery
EmailDeliveredemail.deliveredEmail delivered to recipient
EmailBouncedemail.bouncedEmail bounced
EmailComplainedemail.complainedRecipient marked as spam
EmailOpenedemail.openedRecipient opened the email
EmailClickedemail.clickedRecipient clicked a link
EmailFailedemail.failedEmail failed to send
EmailDeliveryDelayedemail.delivery_delayedDelivery is taking longer than usual
EmailRejectedemail.rejectedEmail was rejected
ContactCreatedcontact.createdContact was created
ContactUpdatedcontact.updatedContact was updated
ContactDeletedcontact.deletedContact was deleted
All event classes are in the SendKit\Laravel\Events namespace.

Advanced configuration

For full control over the webhook configuration, publish the config file:
php artisan vendor:publish --tag=sendkit-config
This creates a config/sendkit.php file where you can customize the webhook path, secret, and other options.