Prompt
How do I send emails from a Laravel app?
Latest observation
Laravel has a built-in mail system powered by Symfony Mailer. The typical flow is:
Configure a mail provider → create a Mailable → send it with Mail::to() → optionally queue it. Laravel supports SMTP and providers such as Postmark, Mailgun, Resend, and Amazon SES. Laravel
1. Configure your mail provider
For example, using SMTP, put the credentials in .env:
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your-username
MAIL_PASSWORD=your-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
The exact host, port, username, and password depend on your email provider.
Laravel reads the mail configuration from config/mail.php. Laravel
2. Create a Mailable
Run:
php artisan make:mail WelcomeEmail
Then define the email:
<?php
namespace App\Mail;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
class WelcomeEmail extends Mailable
{
public function envelope(): Envelope
{
return new Envelope(
subject: 'Welcome to our app!',
);
}
public function content(): Content
{
return new Content(
view: 'emails.welcome',
);
}
}
3. Create the email view
Create:
resources/views/emails/welcome.blade.php
<h1>Welcome!</h1>
<p>Thanks for creating an account with us.</p>
4. Send it
For example, from a controller:
use App\Mail\WelcomeEmail;
use Illuminate\Support\Facades\Mail;
Mail::to($user->email)->send(new WelcomeEmail);
You can also add CC/BCC:
Mail::to($user->email)
->cc('admin@example.com')
->bcc('audit@example.com')
->send(new WelcomeEmail);
This is the standard Laravel Mailable API. Laravel
5. Prefer queues for production
Email sending can slow down an HTTP request, so for transactional emails it's usually better to queue them:
Mail::to($user->email)
->queue(new WelcomeEmail);
Laravel's queue system then sends the email in the background. Laravel+1
You'll need a queue worker running, for example:
php artisan queue:work
For production, you would normally run that worker under a process manager rather than manually in a terminal.
A good production setup
I'd generally use:
Laravel application
│
├── Mailable
│
▼
Queue
│
▼
Queue worker
│
▼
Email provider
│
▼
Recipient
This keeps your web requests fast and lets you retry failed email jobs. Laravel supports multiple queue backends, including database, Redis, and Amazon SQS. Laravel
Official docs: Laravel Mail documentation
If you tell me which email provider you want to use (Gmail, Microsoft 365, Mailgun, Resend, Amazon SES, Postmark, etc.), I can give you the exact .env configuration and Laravel code.
Citations
- https://laravel.com/framework/docs/mail
- https://laravel.com/framework/docs/12.x/queues
- https://laravel.com/framework/docs/11.x/mail
- https://laravel.com/framework/docs/8.x/mail
- https://laravel.com/framework/docs/10.x/mail
- https://laravel.com/framework/docs/5.5/mail
- https://laravel.com/framework/docs/12.x/artisan
- https://laravel.com/framework/docs/5.4/mail
- https://laravel.com/framework/docs/12.x/contracts
- https://laravel.com/framework/docs/5.6/mail
- https://laravel.com/framework/docs/5.1/mail
- https://laravel.com/framework/docs/7.x/mail