uSend Docs
Quickstarts

Send with Laravel

Send email from Laravel with the usend PHP SDK, or through SMTP and the Mail facade.

You need a verified domain and an API key. There are two ways to use usend from Laravel. The SDK calls the API directly (templates, batches, scheduling, idempotency); SMTP keeps your existing Mail:: code. For SMTP see Laravel with SMTP.

Option 1: the PHP SDK

Shell
composer require usend/usend
config/services.php
'usend' => ['key' => env('USEND_API_KEY')],
app/Providers/AppServiceProvider.php
public function register(): void
{
    $this->app->singleton(\Usend\Client::class, fn () => new \Usend\Client(config('services.usend.key')));
}
app/Jobs/SendWelcome.php
public function handle(\Usend\Client $usend): void
{
    $usend->emails->send([
        'from' => 'Acme <[email protected]>',
        'to' => [$this->user->email],
        'subject' => 'Welcome',
        'html' => view('emails.welcome', ['user' => $this->user])->render(),
    ], "welcome-{$this->user->id}");
}

The idempotency key makes a retried queue job safe: usend returns the first result instead of sending again. See Idempotency. A failure throws \Usend\UsendException.

To receive webhooks, call \Usend\Webhook::verify($request->getContent(), $request->headers->all(), config('services.usend.webhook_secret')) in a route excluded from CSRF protection.

Option 2: SMTP and the Mail facade

.env
MAIL_MAILER=smtp
MAIL_HOST=smtp.usend.et
MAIL_PORT=587
MAIL_USERNAME=usend
MAIL_PASSWORD=us_123456789
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME=Acme

Your API key is the password. Mail sent this way shows up in your dashboard logs like any API send.

Without the SDK

Laravel's HTTP client also works: Http::withToken(env('USEND_API_KEY'))->post('https://api.usend.et/emails', [...]).

Next: Send emails.