Last Updated on August 2, 2026 by ian
Laravel’s built-in mail system is one of the most elegant in any framework. This guide shows you how to configure ConvertNow as your Laravel mail driver, send your first email, and use Mailables and Blade templates for production-ready transactional email.
Step 1: Configure your .env
Add these lines to your .env file:
MAIL_MAILER=smtp
MAIL_HOST=out.convertnow.co
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
[email protected]
MAIL_PASSWORD=cn_live_YOUR_KEY
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
Step 2: Send your first email
The quickest way is using the Mail facade with a closure:
use Illuminate\Support\Facades\Mail;
Mail::raw('Hello from Laravel!', function ($message) {
$message
->to('[email protected]')
->subject('Hello from Laravel');
});
// Or with HTML:
Mail::html('<h1>Hello from Laravel!</h1>', function ($message) {
$message
->to('[email protected]')
->subject('Hello from Laravel');
});
Step 3: Create a Mailable class
Mailables are the Laravel-idiomatic way to structure emails. Generate one with Artisan:
php artisan make:mail WelcomeMail
This creates app/Mail/WelcomeMail.php. Update it:
<?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 MyApp, {$this->user->name}!",
);
}
public function content(): Content
{
return new Content(
view: 'emails.welcome',
);
}
}
Step 4: Create a Blade email template
Create resources/views/emails/welcome.blade.php:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Hi {{ $user->name }}!</h1>
<p>Your account is ready.</p>
<p>
<a href="{{ url('/login') }}">
Log in to your account
</a>
</p>
<p>If you did not create an account, no action is required.</p>
</body>
</html>
Step 5: Send the Mailable from a controller
<?php
namespace App\Http\Controllers;
use App\Mail\WelcomeMail;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class AuthController extends Controller
{
public function register(Request $request)
{
$user = User::create($request->validated());
// Send welcome email
Mail::to($user->email)->send(new WelcomeMail($user));
return response()->json(['message' => 'Account created'], 201);
}
}
Step 6: Queue emails for background processing
For production, queue emails so they don’t slow down HTTP responses. Make your Mailable queueable:
use Illuminate\Contracts\Queue\ShouldQueue;
class WelcomeMail extends Mailable implements ShouldQueue
{
// ... same as before
}
Then dispatch it:
// This queues the email instead of sending synchronously
Mail::to($user->email)->queue(new WelcomeMail($user));
Step 7: Send with CC, BCC, and attachments
Mail::to('[email protected]')
->cc('[email protected]')
->bcc('[email protected]')
->send(new InvoiceMail($invoice));
In your Mailable, attach a file:
public function attachments(): array
{
return [
Attachment::fromPath(storage_path('app/invoices/' . $this->invoice->filename))
->as('invoice.pdf')
->withMime('application/pdf'),
];
}
Testing emails in development
Use Laravel’s log mail driver during development to write emails to your log file instead of sending:
# .env (development)
MAIL_MAILER=log
Or use Mailpit (a local email catching tool):
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_ENCRYPTION=null
Start sending for free — convertnow.co — no credit card required

