Skip to main content
Send email and SMS from a Laravel app by plugging Courier into Laravel Notifications as a custom channel. $user->notify(new OrderShipped($order)) queues after the transaction commits, and one Courier call sends both.
Save it as first_send.php, then run it with your API key and email address:
It prints a request id to find in Courier Logs. On a Test key, send to your Courier login address, which test email reaches with no provider connected.

courier-laravel-quickstart

The finished Laravel app from this guide, ready to clone and run.

Build this with a coding agent

To have a coding agent add Courier to your Laravel app, paste this prompt into Claude Code, Cursor, or Codex from the project root:
Install the Courier skill with npx skills add trycourier/courier-skills, and connect the Courier MCP server so the agent can check Courier Logs and templates itself.

Rules for AI agents

  • Use trycourier/courier and $client->send->message(message: [...], idempotencyKey: ...) with camelCase keys, such as userID.
  • Read COURIER_API_KEY through config('services.courier.key'), and call env() only inside config/.
  • Return CourierChannel from via() and build the message in toCourier().
  • Implement ShouldQueue and call $this->afterCommit() in the notification’s constructor.
  • Pass the notification’s id as idempotencyKey, and return new CourierRetryPolicy from middleware() to retry only what Courier runs again.
  • Never call Twilio or your mail provider directly, because Courier routes email and SMS.

What you’ll build

This Laravel app notifies a user through Courier when their order ships:
  • An email and a text from one send, once the shipment commits
  • A CourierChannel that any Laravel notification can use
  • Queue retries that never send twice
Tested in November 2026 with Laravel 13.43, trycourier/courier 8.2.0, and PHP 8.5.

Prerequisites

For the first send

For the full build

Clone the finished Laravel app

Clone the Courier Laravel quickstart to run the finished app with your own key:
The steps below add or change these files:

Install the Courier PHP SDK in Laravel

The Courier PHP SDK is trycourier/courier. Laravel already includes Guzzle, its HTTP client, so install only the SDK:
Add a courier entry to config/services.php:
Read the key through config(), because php artisan config:cache stops Laravel loading .env. Add your key and address to .env, with an optional E.164 DEMO_PHONE:

Add a phone number and an orders table in Laravel

Courier’s SMS channel needs the Laravel user’s phone number. Run php artisan make:model Order and php artisan make:migration create_orders_table, then match the quickstart’s migration:
Run php artisan migrate. Then in app/Models/User.php, add 'phone_number' to $fillable (#[Fillable] on Laravel 13) and these methods. Laravel channels look up the recipient with routeNotificationFor<Channel>().

Send email and SMS from a custom Laravel notification channel

A Laravel notification channel is a class with a send() method, and CourierChannel makes one Courier call to POST /send per notification. The PHP SDK takes camelCase keys, such as userID, and sends them as snake_case.
app/Notifications/Channels/CourierChannel.php

Limit Laravel queue retries to connection errors and rate limits

CourierRetryPolicy lets the Laravel queue retry only the errors Courier runs again for the same idempotency key, and fails the job on any other.
app/Notifications/Channels/CourierRetryPolicy.php

Queue the Laravel notification after the transaction commits

OrderShipped is a standard Laravel notification that via() routes to Courier through CourierChannel, and middleware() adds the retry policy.
app/Notifications/OrderShipped.php

Ship an order and notify the user in Laravel

markShipped() writes the status and calls notify() in one Laravel transaction, so a rolled-back shipment queues no Courier send.
app/Models/Order.php
Call $order->markShipped() from a controller or job, and run a worker for Laravel’s default database queue:

Verify

Ship one order and find it in Courier. In the cloned repo, php artisan courier:send does it on the sync queue and prints the request id:
In your own app, start php artisan queue:work, then run App\Models\Order::first()->markShipped() in php artisan tinker. The worker writes the request id to storage/logs/laravel.log. Open it in Courier Logs to see each channel and provider. A user with no phone number gets email only.

Go to production with Courier

Courier is notification infrastructure for humans and AI agents. Go live moves your Laravel app from Test to Production:
  • Switch keys. Set a Production COURIER_API_KEY and connect your providers in that environment.
  • Keep a worker up. Run queue:work under Supervisor or Laravel Horizon, or queued notifications never send.
  • Honor opt-outs. Add 'preferences' => ['subscriptionTopicID' => ...] to the message so the hosted page’s choices apply.

FAQ

Laravel Notifications and Courier work together, because Courier is one more channel in via(). Keep mail and database, and route SMS, failover, and hosted preferences through CourierChannel.
Laravel sends SMS through Courier when the recipient has an E.164 phoneNumber and routing.channels includes sms. Connect an SMS provider such as Twilio in Courier first.
Laravel runs queued Courier notifications only while php artisan queue:work runs. With QUEUE_CONNECTION=sync, Laravel sends inline after the commit with no retry, so a failed send throws from markShipped() after the order is saved.
Laravel queue retries can’t duplicate a Courier notification, because the notification’s id is the idempotency key. CourierRetryPolicy fails the job on any error Courier would replay for that key.