Laravel
Send an email from a Laravel app with the usenotix/notix-php package.
Send your first email from Laravel with usenotix/notix-php. The package ships a service provider and a Notix facade, and Laravel finds both on its own.
Prerequisites
- An API key.
- A verified domain to send from.
- PHP 8.1 or newer.
Install the package
composer require usenotix/notix-phpSet your API key
Add the key to
.env:NOTIX_API_KEY=notix_12345Then add a
notixentry toconfig/services.php. The provider readsservices.notix.keyfirst and falls back toNOTIX_API_KEY.'notix' => [ 'key' => env('NOTIX_API_KEY'), ],Send an email
Use the facade. A facade proxies static calls, so reach each resource through its method:
Notix::emails().<?php namespace App\Http\Controllers; use Notix\Laravel\Facades\Notix; class OrderController extends Controller { public function receipt() { $email = Notix::emails()->send([ 'from' => 'Acme <receipts@acme.com>', 'to' => 'maria@example.com', 'subject' => 'Your receipt for order 4471', 'html' => '<p>Thanks for your order, Maria.</p>', ]); return response()->json(['emailId' => $email['emailId']]); } }Or inject the client
You can also resolve
Notix\Notixfrom the container. Outside the facade, resources are plain properties.use Notix\Notix; class Receipts { public function __construct(private readonly Notix $notix) { } public function send(string $to): string { $email = $this->notix->emails->send([ 'from' => 'receipts@acme.com', 'to' => $to, 'subject' => 'Your receipt', 'html' => '<p>Thanks for your order.</p>', ]); return $email['emailId']; } }
Already using Laravel's Mail facade? You can point it at the Notix SMTP relay instead. See the SMTP quickstart.
Next steps
- Send many emails at once with batch sending.
- Add files with attachments.
- Make retries safe with idempotency keys.
- Verify webhooks in Laravel with Verify requests. Set
NOTIX_WEBHOOK_SECRETand add'webhook_secret' => env('NOTIX_WEBHOOK_SECRET')to the same config entry.