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

  1. Install the package

    composer require usenotix/notix-php
    
  2. Set your API key

    Add the key to .env:

    NOTIX_API_KEY=notix_12345
    

    Then add a notix entry to config/services.php. The provider reads services.notix.key first and falls back to NOTIX_API_KEY.

    'notix' => [
        'key' => env('NOTIX_API_KEY'),
    ],
    
  3. 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']]);
        }
    }
    
  4. Or inject the client

    You can also resolve Notix\Notix from 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

Open in ClaudeOpen in ChatGPT