# Laravel

Connect Laravel’s mailer to Sendy over SMTP.

Before you begin, verify a sending domain and create an [API key](https://usesendy.com/docs/authentication). This example uses Laravel 12’s SMTP mail configuration.

## Configure the mailer

Set these values in your Laravel application’s `.env` file:

Laravel · .env

```
MAIL_MAILER=smtp
MAIL_SCHEME=smtp
MAIL_HOST=smtp.usesendy.com
MAIL_PORT=2525
MAIL_USERNAME=apikey
MAIL_PASSWORD=API_KEY
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="My App"
```

Replace `API_KEY` with your full API key and `MAIL_FROM_ADDRESS` with an address on your verified domain. Set `MAIL_FROM_NAME` to your application name.

Remove any existing `MAIL_URL` value so it does not override these settings. Use the `smtp` scheme for STARTTLS on port 2525. See [Laravel mail configuration](https://laravel.com/docs/13.x/mail).

Clear cached configuration after changing the settings:

Refresh configuration · terminal

```
php artisan config:clear
```

## Send a test email

Open Laravel’s interactive shell:

Open Tinker · terminal

```
php artisan tinker
```

Replace the recipient with your test address, then run:

Send HTML · Tinker

```
use Illuminate\Support\Facades\Mail;

Mail::html('<h1>Welcome</h1><p>Your account is ready.</p>',
    function ($message) {
        $message->to('recipient@example.com')
            ->subject('Welcome');
    }
);
```

Your existing mailables and notifications can use the same default mailer. The configured sender name and address apply unless the message overrides them.

## Check the result

Open [Emails](https://usesendy.com/emails) to confirm the message was queued and follow its status. A successful SMTP submission confirms queuing, not inbox delivery. See [Errors](https://usesendy.com/docs/errors) if the mailer throws an exception.
