How to Send Transactional Emails in Laravel with Mailofly
Configure Mailofly as your Laravel SMTP or API transport. Seamless integration with Laravel Mailables, Notifications, and asynchronous Queue Workers.
composer require symfony/mailgun-mailer # Optional for API, or use native SMTPGet Up and Running in 3 Easy Steps
Update Laravel .env
Set `MAIL_MAILER=smtp`, `MAIL_HOST=smtp.mailofly.com`, `MAIL_PORT=587`, and your Mailofly API key as `MAIL_PASSWORD`.
Create a Mailable
Generate a Mailable class using `php artisan make:mail OrderShipped` and implement `ShouldQueue` for asynchronous processing.
Dispatch via Mail facade
Call `Mail::to($user)->queue(new OrderShipped($order))` to dispatch transactional emails through Mailofly's relay.
Production-Ready Code Example
Copy and paste into your project. Fully typed and tested.
<?php
namespace App\Mail;
use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class OrderShipped extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct(public Order $order) {}
public function envelope(): Envelope
{
return new Envelope(
subject: "Your Order #{$this->order->id} Has Shipped!",
);
}
public function content(): Content
{
return new Content(
view: 'emails.orders.shipped',
);
}
}
// In your controller:
// use Illuminate\Support\Facades\Mail;
// Mail::to($request->user())->queue(new OrderShipped($order));Engineered for Laravel
Zero Package Overhead
Works natively with Laravel's built-in Symfony Mailer SMTP driver. No third-party packages required.
Asynchronous Queue Integration
Dispatch queued emails effortlessly with Redis, Horizon, or database queue workers for blazing fast page loads.
Automated SPF & DKIM Signing
All outbound Laravel mail is authenticated automatically with your domain's SPF, DKIM, and DMARC records.
Explore Mailofly Infrastructure Capabilities
Build resilient, high-deliverability email systems with our core developer tools.
Frequently Asked Questions about Laravel
Start Sending from Laravel in Minutes
3,000 free emails every month. Copy your API key, run the code snippet, and watch your delivery logs in real time.
