The short answer: install a mail driver for your email API, set MAIL_MAILER in .env, and keep your Mailables and Notifications as they are. Laravel then sends each message as one HTTPS request instead of an SMTP session. With SMTPfast that is one Composer package and two .env lines.
Laravel already ships API drivers for Mailgun, Postmark, Resend and Amazon SES. This guide uses the SMTPfast Laravel driver, which supports Laravel 12 and 13 on PHP 8.2+ (Laravel 13 needs PHP 8.3+). The steps are the same shape for any provider.
API or SMTP: what changes
SMTP (MAIL_MAILER=smtp) |
Email API driver | |
|---|---|---|
| Network | Outbound 587, 465 or 2525, blocked on some cloud hosts | HTTPS on 443 |
| Per message | A multi-step SMTP conversation | One POST request |
| Result | A "250 OK" text reply | An email id you can look up through the API |
| Retries | Your queue | The driver retries with the same idempotency key, then your queue |
| Errors | SMTP reply codes | The API's error message |
| Your code | Mailables, Notifications | The same Mailables and Notifications |
If your host blocks outbound SMTP, the API driver is the fix. See why DigitalOcean blocks SMTP for one common case.
Step 1: install the driver
composer require smtpfast/smtpfast-laravel
The package registers its service provider and the smtpfast mailer itself. You do not need to edit config/mail.php.
Step 2: set two variables
MAIL_MAILER=smtpfast
SMTPFAST_API_KEY=sf_...
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
MAIL_FROM_ADDRESS must be on a domain you verified in SMTPfast: publish the DKIM, SPF and DMARC records it gives you at your DNS host, then verify. See Domains.
Step 3: send as you always do
use App\Mail\OrderShipped;
use Illuminate\Support\Facades\Mail;
Mail::to($request->user())->send(new OrderShipped($order));
// Notifications use the same mailer
$user->notify(new InvoicePaid($invoice));
// Queued mail too
Mail::to($user)->queue(new OrderShipped($order));
Each message becomes one POST /v1/emails request. Mail::send() returns the SMTPfast email id as the message id ($sent->getMessageId()), and the same id is on the MessageSent event, so you can store it next to the order.
To keep another default mailer and use the API only for some mail:
Mail::mailer('smtpfast')->to($user)->send(new OrderShipped($order));
Step 4: mark transactional email
SMTPfast treats email as marketing unless you say otherwise. Marketing email gets a one-click unsubscribe header and skips people who unsubscribed. Receipts, password resets and sign-in codes must reach people who opted out of marketing, so mark them transactional.
For all mail of the mailer:
SMTPFAST_CATEGORY=transactional
Or per Mailable, with a header:
use Illuminate\Mail\Mailables\Headers;
public function headers(): Headers
{
return new Headers(text: ['X-SMTPfast-Category' => 'transactional']);
}
X-SMTPfast-Track-Opens and X-SMTPfast-Track-Clicks set to true or false work the same way.
What the driver sends
| Laravel message | API field |
|---|---|
| From | from |
| To, Cc, Bcc | to, cc, bcc |
| Reply-To | reply_to |
| Subject | subject |
| HTML and text views | html and text |
| Attachments | attachments (base64) |
$message->embed() inline images |
attachments with content_id |
metadata() |
tags |
Other headers, including tag() |
headers |
An error from the API is thrown as a Symfony TransportException with the API's message, so a failed queued job shows the reason in failed_jobs.
Step 5: receive bounce and delivery events
Webhooks are on paid plans. Set the signing secret and a path, and the package adds the route and checks the signature:
SMTPFAST_WEBHOOK_SECRET=whsec_...
SMTPFAST_WEBHOOK_PATH=smtpfast/webhook
use Illuminate\Support\Facades\Event;
use SMTPfast\Laravel\Events\WebhookReceived;
Event::listen(function (WebhookReceived $event) {
if ($event->payload['type'] === 'email.bounced') {
// flag the address in your users table
}
});
The route answers 401 when the X-SMTPfast-Signature header does not match, and it has no session or CSRF middleware.
Without a package: the HTTP client
If you only send one or two emails and do not want a driver, Laravel's HTTP client is enough:
use Illuminate\Support\Facades\Http;
$response = Http::withToken(config('services.smtpfast.key'))
->post('https://smtpfa.st/api/v1/emails', [
'from' => 'Acme <[email protected]>',
'to' => [$user->email],
'subject' => 'Your receipt',
'html' => view('emails.receipt', ['order' => $order])->render(),
'category' => 'transactional',
])
->throw();
$emailId = $response->json('id');
You lose the Mailable features (queues, Markdown mail, notifications), so the driver is the better default for an app that sends more than a few kinds of email.
Checklist
MAIL_FROM_ADDRESSis on a verified domain. Check the records with the SPF, DKIM and DMARC checkers.- The API key is only in
.envor your secret store, with theemail:sendscope. - Password resets, verification emails and receipts are transactional.
- Queued mail has a retry policy, and
failed_jobsis monitored.
The SDK docs cover the PHP client the driver uses, which you can also inject as SMTPfast\Client for domains, contacts and the rest of the API. To compare providers first, see email API prices and free tiers.
Frequently asked questions
How do I send email from Laravel with an API instead of SMTP?
Use an API mail driver. Laravel ships drivers for Mailgun, Postmark, Resend and Amazon SES, and providers such as SMTPfast publish their own (composer require smtpfast/smtpfast-laravel). Set MAIL_MAILER to the driver name and add the API key to .env. Mailables, Notifications and queued mail keep working without code changes.
Why use an email API instead of SMTP in Laravel?
An API send is one HTTPS request on port 443, which hosts do not block, and it returns an id for the message, so you can look up delivery later. SMTP needs an open outbound port (587, 465 or 2525), and a longer conversation per message, and the reply is a line of text rather than an id you can query through an API. Some cloud hosts block outbound SMTP ports on new accounts.
Do I need to change my Mailables to use an email API?
No. The mail driver turns the Symfony message Laravel builds into the API request: from, to, cc, bcc, reply-to, subject, HTML and text views, attachments and inline images. You only change .env, and optionally add a header to choose transactional or marketing per Mailable.
Which Laravel versions does the SMTPfast mail driver support?
Laravel 12 and 13 on PHP 8.2 or newer (Laravel 13 needs PHP 8.3 or newer).
Ready to get started?
Start sending transactional email today. Free to start, no credit card required.
Get Started for FreeRelated Posts
Cheapest Transactional Email API in 2026: Free Tiers and Prices Compared
Amazon SES is the cheapest per email at $0.10 per 1,000, but you wire up bounce handling and logs yourself. Among managed email APIs, Mailjet (6,000 a month) and Mailtrap (4,000) have the largest monthly free tiers, and SMTPfast has the lowest price we found at 50,000 and 100,000 emails a month ($19). Every price below was checked on the provider's own pricing page on 21 November 2026.
How to Check the SPF, DKIM and DMARC Records for Your Domain
Look up three DNS TXT records: SPF at the domain itself (v=spf1), DKIM at selector._domainkey.yourdomain.com (v=DKIM1, or a CNAME to your provider), and DMARC at _dmarc.yourdomain.com (v=DMARC1). Use dig on macOS and Linux, nslookup on Windows, or a free online checker, then send a real test email to confirm all three pass.