Laravel has a clean mail system built on the Symfony Mailer component. You describe a message as a mailable class, point the framework at an SMTP server with a few lines in your .env file and send with one call. Most problems people report ("Laravel mail not sending", "failed to authenticate on SMTP server", "connection could not be established") come from the same few places: settings that do not match the port, an old cached configuration, special characters in a password and mail that runs in a web request instead of a queue. This guide covers the settings for current and older Laravel versions, a first mailable, queued sending, how to test safely, how to read the common errors and how to improve deliverability. Use the SMTP host, user name and password from your provider's dashboard. The values in the examples are placeholders.
The .env settings
Laravel reads mail settings from config/mail.php, which in turn reads environment variables. The names changed slightly in Laravel 11, so check which version you run with php artisan --version.
# Laravel 11 and later
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your-smtp-user
MAIL_PASSWORD="your-smtp-password"
MAIL_SCHEME=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
# Laravel 10 and earlier
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your-smtp-user
MAIL_PASSWORD="your-smtp-password"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"The difference is how encryption is chosen. In Laravel 10 and earlier, MAIL_ENCRYPTION=tls means STARTTLS on port 587 and ssl means implicit TLS on port 465. In Laravel 11 and later, the Symfony mailer uses STARTTLS automatically when the server offers it, and MAIL_SCHEME is only needed when you want implicit TLS on port 465: set it to smtps. Leave it empty or null for port 587. If you see an error about a wrong version number, the port and the scheme do not match. Our guide on which SMTP port to use explains why.
| Variable | Meaning | Notes |
|---|---|---|
MAIL_MAILER | Which driver to use | smtp for a relay, log to write mail to the log file during development, array in tests |
MAIL_HOST | SMTP server name | Copy it from your provider, not from a tutorial |
MAIL_PORT | Connection port | 587 for STARTTLS, 465 for implicit TLS |
MAIL_USERNAME / MAIL_PASSWORD | Credentials | Wrap the password in double quotes if it contains #, spaces or $ |
MAIL_FROM_ADDRESS | Default sender | Use an address on a domain you have authenticated |
MAIL_FROM_NAME | Default sender name | Shown to recipients, so keep it recognisable |
A frequent trap is the hash sign. In an .env file, an unquoted # starts a comment, so a password that contains one is cut off and the server answers with an authentication error. Quote the value. A dollar sign can also be treated as a variable reference. If you build credentials into a connection string with MAIL_URL, percent-encode special characters, as described in SMTP error 535.
Clear cached configuration after every change
This is the single most common reason that "the settings are right but nothing changed". When you run php artisan config:cache, which is standard in production, Laravel stores the configuration in a file and stops reading .env at runtime. Editing .env afterwards has no effect until you rebuild the cache. Run these commands after any mail change, and restart queue workers, because a worker keeps the old configuration in memory.
php artisan config:clear
php artisan config:cache
php artisan queue:restartCreate and send a mailable
A mailable describes one kind of message. Generate it with Artisan, then fill in the envelope (subject and addresses), the content (the view) and any attachments.
php artisan make:mail WelcomeMail --markdown=emails.welcome<?php
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class WelcomeMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public User $user) {}
public function envelope(): Envelope
{
return new Envelope(subject: 'Welcome to ' . config('app.name'));
}
public function content(): Content
{
return new Content(markdown: 'emails.welcome', with: ['name' => $this->user->name]);
}
}Send it from a controller, a job or an event listener:
use App\Mail\WelcomeMail;
use Illuminate\Support\Facades\Mail;
Mail::to($user->email)->send(new WelcomeMail($user));Markdown mailables give you responsive HTML and a plain-text version from a single template, which suits transactional messages well. If you write your own HTML, add a text version as well, because filters penalise HTML-only mail. See HTML email templates for rendering tips.
Queue your mail
Sending inside the web request makes the user wait for an SMTP conversation, and a slow server slows your page. Queue the message instead. Either call Mail::to($user)->queue(new WelcomeMail($user)) or make the mailable implement ShouldQueue. Then run a worker with php artisan queue:work and keep it running under a process manager such as Supervisor or systemd. Use a real queue driver such as the database, Redis or SQS in production, because the sync driver runs jobs immediately and defeats the purpose.
Queued mail needs a plan for failures. Set $tries and a backoff so that temporary SMTP errors are retried with a growing delay, and let permanent errors fail quickly. Inspect failed jobs with php artisan queue:failed and retry them with php artisan queue:retry all once the cause is fixed. A queue that silently retries a rejected login every few seconds can trigger a provider block, so alert on repeated failures. Our guide rate limits, retries and backoff and the design notes in reliable email sending queues go deeper.
Test without sending real mail
- Set
MAIL_MAILER=login local development. Messages are written tostorage/logs/laravel.logso you can check content and headers. - Use
Mail::fake()in automated tests, then assert that a mailable was sent or queued, without touching SMTP. - Send a one-line test from
php artisan tinkerto prove the connection and credentials before you debug your templates.
Mail::raw('SMTP test from Laravel', function ($m) {
$m->to('[email protected]')->subject('SMTP test');
});If this raw send works but your mailable does not, the problem is in the mailable or the queue, not in the SMTP settings. If it fails, read the exception message first, because Symfony Mailer is specific about the stage that failed.
Common errors and fixes
| Error text | Usual cause | Fix |
|---|---|---|
| Failed to authenticate on SMTP server with username ... using the authenticators ... | Wrong credentials, unquoted special characters or the wrong credential type | Re-copy the credentials, quote the password in .env and clear the config cache |
| Connection could not be established with host ... timed out | Port blocked by a firewall or the host name is wrong | Test the host and port with openssl s_client from the same server |
| Unable to connect with STARTTLS / wrong version number | Port and encryption settings do not match | Use 587 with STARTTLS or 465 with smtps in Laravel 11 and later |
| Expected response code "250" but got code "550" | The server rejected the sender or recipient | Read the reply text. Use a verified From domain and a valid recipient |
| Mail works locally but not in production | Cached config, a different .env or workers still using old values | Run config:clear and queue:restart, and check the production .env |
| Queued mail never sends | No worker is running or the queue name differs | Start queue:work and check failed_jobs |
| Emails send but land in spam | Domain not authenticated or poor content | Publish SPF, DKIM and DMARC and review the content |
Deliverability for Laravel mail
Laravel gives you a correctly formed message. Whether it reaches the inbox depends on your domain and sending practices. Authenticate the domain in the From address with SPF, DKIM and DMARC, and test the result with the SPF, DKIM and DMARC checker. Keep password resets, receipts and alerts separate from newsletters, ideally on different subdomains, so that complaints about marketing mail cannot affect critical messages. Remove hard-bounced addresses from your user table or a suppression list rather than retrying them forever. Our guides on authenticating your domain and suppression lists explain both.
Finally, consider whether SMTP is the right transport as you grow. An email API gives you structured responses and event webhooks for delivered, bounced and complained messages, which you can store against your own records. Laravel's mail layer supports API-based transports through packages, and our comparison of SMTP and API sending helps you decide.
Send Laravel mail through a managed relay Copy the SMTP host and credentials from your dashboard and set your .env in minutes.
References and further reading
Frequently asked questions
Why does Laravel not use my new .env mail settings?
If you ran config:cache, Laravel reads the cached configuration. Run php artisan config:clear, then config:cache again, and restart queue workers so they load the new values.
What is MAIL_SCHEME in Laravel 11?
It selects the transport scheme. Leave it empty for port 587 where STARTTLS is used automatically, and set it to smtps for implicit TLS on port 465.
Why does my password with a # fail?
In .env, an unquoted # starts a comment, so the password is cut off. Wrap the value in double quotes.
Should I queue emails in Laravel?
Yes for most applications. Queueing keeps pages fast and lets failed messages be retried. Use a real queue driver and keep a worker running.
How can I test Laravel mail locally?
Use MAIL_MAILER=log to write messages to the log, Mail::fake() in tests, and a raw send from tinker to confirm SMTP credentials.