Skip to content

Search documentation

Search pages and sections

Integrations

Laravel

Use Hulaki as a Laravel mail transport — Mailables and notifications just work — and receive webhooks as Laravel events.

The hulakimail/laravel package supports Laravel 11 and 12 on PHP 8.2+.

Install

composer require hulakimail/laravel
php artisan vendor:publish --tag=hulakimail-config   # optional

Configure the mailer

Add a mailer to config/mail.php and set your environment:

config/mail.php
'mailers' => [
    // ...
    'hulakimail' => [
        'transport' => 'hulakimail',
    ],
],
.env
MAIL_MAILER=hulakimail
MAIL_FROM_ADDRESS[email protected]
MAIL_FROM_NAME="Acme"
HULAKIMAIL_API_KEY=hm_live_...

Sending

Nothing else changes — Mailables, notifications and queued mail go through Hulaki:

use App\Mail\OrderShipped;
use Illuminate\Support\Facades\Mail;

Mail::to($order->customer)->send(new OrderShipped($order));

// Tags and metadata become Hulaki tags/metadata
public function envelope(): Envelope
{
    return new Envelope(
        subject: 'Your order has shipped',
        tags: ['order-shipped'],
        metadata: ['order_id' => $this->order->id],
    );
}

Webhooks as events

Set HULAKIMAIL_WEBHOOK_SECRET to your endpoint’s signing secret and point the webhook endpoint at https://your-app.com/hulakimail/webhook. The package verifies the signature and dispatches a Laravel event per type:

Webhook typeLaravel event
email.sentEmailSent
email.deliveredEmailDelivered
email.delivery_delayedEmailDeliveryDelayed
email.bouncedEmailBounced
email.complainedEmailComplained
email.opened / email.clickedEmailOpened / EmailClicked
email.failedEmailFailed
email.suppressed / email.unsubscribedEmailSuppressed / EmailUnsubscribed
anyWebhookReceived
use HulakiMail\Laravel\Events\EmailBounced;
use Illuminate\Support\Facades\Event;

Event::listen(function (EmailBounced $event) {
    User::where('email', $event->recipient())->update(['email_bounced' => true]);
});

Configuration reference

Env variableDefaultPurpose
HULAKIMAIL_API_KEY—API key with the emails:send scope
HULAKIMAIL_TIMEOUT30Seconds per HTTP request
HULAKIMAIL_TRACK_OPENS / _CLICKSdomain defaultForce tracking on or off
HULAKIMAIL_WEBHOOK_SECRET—Enables the webhook route
HULAKIMAIL_WEBHOOK_PATHhulakimail/webhookWebhook route path
HULAKIMAIL_WEBHOOK_TOLERANCE300Max signature age in seconds

Something unclear or missing? Tell us.