2mail — SMTP relay from Belgian infrastructure

SMTP for Laravel — application mail that arrives

Laravel ships with a full mail layer, including queues, templates and notifications. What it does not provide is deliverability: that depends on the server you send through, and the default configuration on a fresh server rarely makes a good sender.

Laravel reads its mail settings from the environment configuration. You change the SMTP details there and the rest of your application stays untouched — no changes to mailables, notifications or queues needed.

Why it goes wrong without a relay

An application in development sends to a test address and everything looks fine. At go-live the audience changes: real addresses at real providers, which do check authentication and reputation. That is the moment password reset emails suddenly stop arriving — for a subset of users, which makes it hard to spot.

Setting up SMTP in Laravel

1

Collect your details

Log in to your 2mail account and retrieve your SMTP server, username and password there.

2

Fill them in inside Laravel

The mail settings live in your application's environment file, not in the code. You set the mailer to SMTP and fill in the five details below. Do not forget the sender address and sender name: those are separate settings alongside the connection details.

3

Authenticate your domain

Make sure SPF, DKIM and DMARC are set correctly for your domain, so recipients can verify that the mail comes from you.

4

Test

Send a test message to an address at a major provider and check that it arrives in the inbox and not in the spam folder.

The fields Laravel asks for

Every platform names them slightly differently, but it is always the same five. The actual values are tied to your account and can be found in your 2mail account — take them from there, so you are sure to use the right ones.

Field What you enter
SMTP server (host)The server name from your 2mail account.
PortThe port that matches your chosen encryption; your account shows which one.
EncryptionTLS. Never send unencrypted — your credentials would otherwise travel in plain text.
UsernameThe SMTP login of your 2mail account.
PasswordThe matching password. Never use the password of an employee's mailbox.

Which emails Laravel sends

As soon as the relay is set up, all of these run through 2mail — you do not have to configure them one by one.

Password resets and email verification
Notifications and event mail from the application
Invoices and subscription messages
Reports from scheduled tasks
Error notifications to administrators

Pitfalls with Laravel

The queue has to be running

If you queue mail without an active worker, nothing leaves and you see no error at all. On a delivery problem this should be the first check, not the last.

Configuration cache after a change

If your application runs with a cached configuration, changed mail settings have no effect until that cache is refreshed. A setting that "does not work" often simply has not been re-read yet.

Test environments that really send

A staging environment with a copy of the production database can send to real customers unnoticed. Restrict the recipients there explicitly, or use a separate login.

SPF, DKIM & DMARC explained About deliverability

A different platform?

SMTP is a standard protocol: any system that speaks SMTP — a CRM, an ERP, a custom application or a server — can send through 2mail using the same five fields.

Frequently asked questions about SMTP for Laravel

Laravel provides the mail layer, not deliverability: that depends on the server you send through. The default configuration on a fresh server rarely makes a good sender, because there is no authentication and no established reputation.
In your application's environment file, not in the code. You set the mailer to SMTP and fill in host, port, username, password and encryption. Do not forget the sender address and sender name — those are separate settings alongside.
If your application runs with a cached configuration, changed mail settings have no effect until that cache is refreshed. A setting that 'does not work' often simply has not been re-read yet.
Check that the queue is being processed. If you queue mail without an active worker, nothing leaves and no error appears either. This should be the first check, not the last.
A staging environment with a copy of the production database can send to real addresses unnoticed. Restrict the recipients there explicitly, or use a separate login so you can track that traffic separately.
Trust Guard Security Scanned
Call us
Send an email