pulsesend-laravel maintained by pulsesend
PulseSend for Laravel
Send your Laravel mail through PulseSend: your Mailables and notifications keep working as they are.
Install
composer require pulsesend/pulsesend-laravel
Requires PHP 8.2 and Laravel 11, 12 or 13.
Configure
PULSESEND_API_KEY=ps_live_xxxxxxxxx
Add a mailer in config/mail.php:
'mailers' => [
// ...
'pulsesend' => [
'transport' => 'pulsesend',
],
],
Then use it:
MAIL_MAILER=pulsesend
MAIL_FROM_ADDRESS=hello@acme.com
MAIL_FROM_NAME=Acme
Send
With Laravel's mail, nothing changes:
Mail::to($request->user())->send(new OrderShipped($order));
Or with the PulseSend facade, for everything the API offers (templates, scheduling, batches, tracking):
use PulseSend\Laravel\Facades\PulseSend;
PulseSend::emails()->send([
'from' => 'Acme <hello@acme.com>',
'to' => [$request->user()->email],
'subject' => 'hello world',
'html' => (new OrderShipped($order))->render(),
]);
The transport sends addresses, subject, bodies, attachments (inline images included), your custom headers and the Mailable's tags. The email id comes back in the X-PulseSend-Email-ID header of the sent message. Add a PulseSend-Idempotency-Key header to a message to make retries safe.
Webhooks
The package answers POST /pulsesend/webhook and dispatches a Laravel event per PulseSend event: email.delivered dispatches PulseSend\Laravel\Events\EmailDelivered.
- Add
https://your-app.com/pulsesend/webhookas an endpoint in the PulseSend dashboard. - Copy its signing secret into
.env:
PULSESEND_WEBHOOK_SECRET=...
- Listen:
Event::listen(function (\PulseSend\Laravel\Events\EmailBounced $event) {
$event->payload['data']['email_id'];
});
The route is registered only once PULSESEND_WEBHOOK_SECRET is set (PULSESEND_ROUTES=false turns it off, true keeps it without a secret). It sits outside the web middleware group, so CSRF doesn't apply.
Without PULSESEND_API_KEY, the app still boots: only an actual send throws ApiKeyIsMissing.
License
MIT