Skip to content
send.io
All posts

Laravel email verification: setup and implementation guide

Laravel email verification requires the MustVerifyEmail contract, verified middleware, and email_verified_at column to work properly. This guide covers production implementation with send.io Contact Verification API to prevent hard bounces and delivery webhooks for real time tracking.

On this page
TL;DR: Laravel's native email verification requires implementing the MustVerifyEmail contract on your User model, protecting routes with the verified middleware, and adding an email_verified_at timestamp column to your users table. For bulk contact imports, run send.io's contact verification on the imported list before sending verification emails, which keeps known-invalid addresses out of your sending and reduces the hard bounces that damage sender reputation. For organic signups, rely on the native flow and bounce webhooks, and implement idempotent webhook handlers to track delivery and bounce events in real time. The webhook signature example in this guide is a generic placeholder, so confirm send.io's signing scheme in the API documentation before deploying the handler.

Calling $user->sendEmailVerificationNotification() returns without error as soon as your mail transport accepts the message. If the address later hard bounces, Laravel never hears about it: the user stays unverified, and the bounce counts against your sender reputation. The native flow covers the contract, middleware, and migration; it doesn't cover pre-send validation or delivery observability. This guide covers the complete native implementation, then shows how send.io's contact verification on import and delivery webhooks tell you whether a verification email actually landed.

The native Laravel verification flow gives you the framework: the MustVerifyEmail contract, route protection, and a signed URL system. What it doesn't give you is pre-send validation or delivery observability. You'll implement both here.

How Laravel email verification works

Laravel's email verification system operates on three coordinated pieces that must work together: a contract on your User model, a middleware that gates routes, and a database column that tracks verification state. If one is missing, verification fails in an observable way:

  • No MustVerifyEmail contract: Laravel doesn't send a verification email.
  • No verified middleware: Unverified users reach protected routes.
  • No email_verified_at column: Laravel can't save the verification timestamp.

Enabling verification for Laravel users

The MustVerifyEmail contract enables Laravel's verification-email flow on your User model, but it doesn't restrict access on its own. You still apply the verified middleware to protected routes, as mailfloss's Laravel guide explains. The contract lives at Illuminate\Contracts\Auth\MustVerifyEmail and declares four methods: hasVerifiedEmail(), markEmailAsVerified(), sendEmailVerificationNotification(), and getEmailForVerification().

Managing request verification pipelines

The verified middleware intercepts requests to protected routes and checks whether the authenticated user has a non-null email_verified_at timestamp. If verification is missing, the middleware either redirects to a verification notice page for web requests or returns a 403 JSON response for API requests. This happens before your controller logic runs, so unverified users can't reach protected operations.

Necessary database migrations

Laravel expects an email_verified_at column on your users table, defined as a nullable timestamp. The column stays null after registration, and Laravel sets it to the current time when the user clicks the signed verification link. The framework's default user migration includes this column.

Laravel email verification: a practical setup

You'll implement the native verification flow first, then add send.io for email delivery. The native setup only requires changes to your User model, your routes file, and one migration.

User model email verification setup

Open your app/Models/User.php file and implement the MustVerifyEmail contract:

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;

// The contract methods are already implemented
// in the Authenticatable base class
}

The Authenticatable base class provides default implementations for all four contract methods: hasVerifiedEmail(), markEmailAsVerified(), sendEmailVerificationNotification(), and getEmailForVerification(). Override them only if you're customizing behavior, such as sending verification through a different notification channel.

Register email verification handlers

Laravel's verification system requires three routes:

  1. Verification notice page: Shows unverified users where to find their verification email.
  2. Verification endpoint: Processes the signed verification link.
  3. Resend endpoint: Lets users request a new verification email.

Add these to your routes/web.php file:

use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

// Show the "verify your email" notice
Route::get('/email/verify', function () {
return view('auth.verify-email');
})->middleware('auth')->name('verification.notice');

// Handle the verification link click
Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
$request->fulfill();
return redirect('/dashboard');
})->middleware(['auth', 'signed'])->name('verification.verify');

// Resend the verification email
Route::post('/email/resend', function (Request $request) {
$request->user()->sendEmailVerificationNotification();
return back()->with('message', 'Verification link sent!');
})->middleware(['auth', 'throttle:6,1'])->name('verification.resend');

The EmailVerificationRequest class validates the signed URL and user ID hash before marking the email as verified. The signed middleware prevents URL tampering, and the throttle middleware on the resend route limits abuse to 6 requests per minute.

Protect routes with verification

Apply the verified middleware to any route that requires a confirmed email address:

Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/dashboard', [DashboardController::class, 'index']);
Route::post('/api/projects', [ProjectController::class, 'store']);
Route::get('/settings', [SettingsController::class, 'show']);
});

When an unverified user hits these routes, Laravel redirects them to the verification notice page for web requests. For API requests, the verified middleware returns a 403 response with the message "Your email address is not verified."

Schema update for email verification

Fresh Laravel installations include the email_verified_at column by default. For existing databases, create a new migration:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('email_verified_at')->nullable()->after('email');
});
}

public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('email_verified_at');
});
}
};

Run php artisan migrate to apply the change. The column must be nullable because new registrations start in an unverified state.

Configure transactional email delivery

Laravel's mail configuration determines how verification emails reach user inboxes. Production requires a real SMTP provider or API integration. send.io offers both SMTP relay and REST API options. SMTP relay works with Laravel's built-in smtp mailer through environment variables, so you can use it without adding a send.io-specific package.

Configure send.io SMTP credentials

send.io returns your SMTP password once, at mailbox creation. Copy it into your secrets manager or .env file at that point.

Setting

Value

Notes

Host

smtp.send.io

Standard SMTP relay endpoint

Port

587

Submission port with STARTTLS

Encryption

STARTTLS

Upgrades plain connection to TLS

Authentication

PLAIN or LOGIN

Username and password returned once at mailbox creation

The SMTP password is tied to the mailbox, so credential rotation happens at the mailbox level rather than per domain or globally. The same password also works as an API key scoped to sending from that mailbox's domain, so treat it as an API credential, not just an SMTP login. Rotating a mailbox's password with POST /mailboxes/{id}/password revokes the old one immediately, so update your .env file or secrets manager right away. Because send.io returns the password only once, a lost password can't be retrieved: use the same rotation endpoint to issue a new one.

Configure send.io for Laravel mail

Update your config/mail.php or .env file to route mail through send.io:

MAIL_MAILER=smtp
MAIL_HOST=smtp.send.io
MAIL_PORT=587
MAIL_USERNAME=your-sendio-smtp-username
MAIL_PASSWORD=your-sendio-smtp-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@yourdomain.com
MAIL_FROM_NAME="${APP_NAME}"

Laravel reads these environment variables and builds the SMTP transport from them. The MAIL_FROM_ADDRESS must be on your verified domain. See the send.io SMTP documentation for the authentication requirements.

Verify Laravel mailer connectivity

Test the connection before deploying to production:

php artisan tinker

Mail::raw('Test email from Laravel', function ($message) {
$message->to('you@example.com')->subject('SMTP Test');
});

If the send succeeds, the message appears in your send.io dashboard logs with a delivery event. In Laravel 9 and later, which use Symfony Mailer, authentication failures throw a Symfony\Component\Mailer\Exception\TransportException with the SMTP error code. Check the send.io SMTP documentation for troubleshooting steps.

Tailor Laravel verification email templates

The default Laravel verification email works but carries generic messaging. Customize the notification to match your application's branding.

Defining a custom notification handler

Override the sendEmailVerificationNotification method in your User model to send a custom notification:

use App\Notifications\CustomVerifyEmail;

public function sendEmailVerificationNotification()
{
$this->notify(new CustomVerifyEmail);
}

Create the custom notification class:

<?php

namespace App\Notifications;

use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Notifications\Messages\MailMessage;

class CustomVerifyEmail extends VerifyEmail
{
protected function buildMailMessage($url)
{
return (new MailMessage)
->subject('Verify your email address')
->line('Click the button below to verify your email address.')
->action('Verify Email', $url)
->line('This verification link expires in 60 minutes.')
->line('If you did not create an account, no further action is required.');
}
}

The parent VerifyEmail class handles URL generation and signing. You're only customizing the presentation layer.

Modifying verification email design

Laravel's verification email is built from the notification's MailMessage, which renders through Markdown mail components. The notification email template lives in resources/views/vendor/notifications once published, while the Markdown mail components (header, footer, button, and themes) publish separately to resources/views/vendor/mail. Publish the notification templates:

php artisan vendor:publish --tag=laravel-notifications

This copies the notification email template into resources/views/vendor/notifications, where you can modify its structure. To change the layout, colors, and component styling, publish the Markdown mail components too with php artisan vendor:publish --tag=laravel-mail, which copies them into resources/views/vendor/mail.

Set custom verification URL

If you need to change the verification URL structure or add tracking parameters, override the verificationUrl method in your custom notification:

protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(60),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
'source' => 'email'
]
);
}

The signed URL includes a signature that the signed middleware validates before processing the verification, and EmailVerificationRequest then validates the id and hash parameters. The default 60-minute expiration is configurable. "The VerifyEmail notification reads the expiration from Config::get('auth.verification.expire', 60) when it builds the signed URL, and falls back to 60 minutes when no value is set. To change it, add an expire value in minutes under the verification key in config/auth.php, as Bannister's walkthrough shows.

Implementing idempotent webhook event handlers

Delivery webhooks tell you whether a verification email landed after you send it. send.io fires webhook events for deliveries, bounces, and complaints, each carrying message metadata and failure diagnostics. Make your webhook handlers idempotent so a duplicate delivery of the same event never processes twice.

Set up verified webhook URL routes

Create a dedicated route for send.io webhooks that bypasses CSRF protection:

// routes/api.php
Route::post('/webhooks/sendio', [SendioWebhookController::class, 'handle'])
->name('webhooks.sendio');

Register the webhook endpoint for your domain using the webhooks section of the send.io API documentation. send.io sends a POST request with a JSON payload to this URL whenever a delivery event occurs. The payload carries metadata and diagnostics, such as the message ID, event type, timestamp, and recipient, but never the message content. Your handler can identify and act on an event, but it can't read the body of the email that triggered it.

Validating incoming webhook signatures

Verify webhook signatures before processing any payload to prevent spoofed events. The signing scheme in this example is a generic HMAC pattern, not send.io's documented scheme. Confirm the header name, signing algorithm, and secret format in the send.io API documentation before you implement it. Until then, the header name, algorithm, and secret below are placeholders read from config:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SendioWebhookController extends Controller
{
public function handle(Request $request)
{
if (!$this->hasValidSignature($request)) {
abort(401, 'Invalid signature');
}

// Process the webhook
$event = $request->input('event');
$messageId = $request->input('message_id');

// Idempotency check using the message ID
if ($this->alreadyProcessed($messageId, $event)) {
return response()->json(['status' => 'duplicate']);
}

// Handle the event
match($event) {
'delivered' => $this->handleDelivery($request->all()),
'bounced' => $this->handleBounce($request->all()),
'complained' => $this->handleComplaint($request->all()),
default => null
};

return response()->json(['status' => 'processed']);
}

private function hasValidSignature(Request $request): bool
{
// PLACEHOLDER: this generic HMAC check is NOT send.io's documented
// signing scheme. Before implementing, confirm the signature header,
// algorithm, and secret format in the send.io API documentation
// (https://developer.send.io/docs/api#webhooks), then set the values
// in config/services.php. Replace this method entirely if send.io
// documents a different signing scheme.
$signature = $request->header(
config('services.sendio.webhook_signature_header')
);

if (!$signature) {
return false;
}

$expectedSignature = hash_hmac(
config('services.sendio.webhook_signature_algorithm'),
$request->getContent(),
config('services.sendio.webhook_secret')
);

return hash_equals($expectedSignature, $signature);
}

private function alreadyProcessed($messageId, $event)
{
// Check your database for an existing record
return \DB::table('webhook_events')
->where('message_id', $messageId)
->where('event_type', $event)
->exists();
}
}

Store the webhook secret in your .env file and never commit it to version control. The handler above illustrates a general pattern, not send.io's documented signing method. It computes an HMAC over the request body, a common pattern among API providers for webhook signing. It signs the raw request body from $request->getContent() instead of re-serialized JSON, and it compares signatures with hash_equals(), a constant-time function, instead of ===. HMAC alone doesn't stop an attacker from replaying a captured request. Check the send.io API documentation to see whether webhook requests include a signed timestamp, and add a short tolerance window only if they do.

The message ID check in the handler also limits the effect of duplicate deliveries. After you confirm the signing scheme in the send.io API documentation, set the placeholder values in config/services.php under the sendio key: webhook_signature_header, webhook_signature_algorithm, and webhook_secret. Don't deploy the handler with the placeholders unchanged.

Managing failed delivery webhooks

Bounce webhooks require immediate action to prevent sender reputation damage. When send.io reports a hard bounce (permanent failure), add the address to your suppression list:

private function handleBounce($payload)
{
$bounceType = $payload['bounce']['type'];
$recipient = $payload['recipient'];

if ($bounceType === 'Permanent') {
// Hard bounce - suppress immediately
\DB::table('email_suppressions')->insert([
'email' => $recipient,
'reason' => 'hard_bounce',
'diagnostic_code' => $payload['bounce']['diagnostic_code'],
'created_at' => now()
]);

// Optionally notify your team
Log::warning("Hard bounce detected", [
'email' => $recipient,
'diagnostic' => $payload['bounce']['message']
]);
}
}

Verify imported contacts before sending

Verifying addresses when you import a contact list catches invalid ones before they trigger a verification email send. send.io, like other email providers, tracks hard bounce rates as a sender reputation signal, and exceeding its bounce thresholds suspends your sending, as the threshold table below shows. This approach fits bulk imports and migrations. For single organic signups, rely on the native verification flow and the bounce webhooks described above.

Filter invalid addresses before importing users

Sending verification emails to invalid addresses wastes send quota and damages sender reputation. send.io's contact verification runs when you import contacts and assigns one of four statuses to each address: valid, invalid, risky, or unknown. Confirm the exact request and response shape in the send.io API documentation before building.

send.io contact verification on import assigns one of four statuses:

  • valid: Address exists and accepts mail
  • invalid: Address doesn't exist or server rejects it
  • risky: Address has quality issues (role-based, disposable, complaint history)
  • unknown: Verification service couldn't determine validity

Broadcasts skip contacts with an invalid status, so a verified list keeps known-invalid addresses out of broadcast sends without extra filtering in your code.

Verify contacts on import

Verify the imported list in a batch before creating user records or sending any verification emails:

use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;

public function importUsers(array $emails)
{
// Submit the imported list for verification before any verification
// emails go out. Set the endpoint URL in config/services.php after
// confirming the import-time contact verification behavior in the
// send.io API documentation (https://developer.send.io/docs/api).
$verification = Http::withHeaders([
'Authorization' => 'Bearer ' . config('services.sendio.api_key'),
'Content-Type' => 'application/json'
])->post(config('services.sendio.contact_verification_url'), [
'emails' => $emails
]);

// Assumed response shape: a list of {email, status} objects.
// Match this to the payload documented by send.io.
$results = collect($verification->json('results', []));

foreach ($results as $result) {
// Skip addresses that failed verification
if ($result['status'] === 'invalid') {
continue;
}

$user = User::firstOrCreate(
['email' => $result['email']],
['password' => bcrypt(Str::random(32))]
);

// Only send verification if status is valid or unknown
if (in_array($result['status'], ['valid', 'unknown'])) {
$user->sendEmailVerificationNotification();
}
}
}

Run verification inside the import job rather than the registration request, so a slow lookup doesn't hold up a signup. Check the send.io contact verification documentation for import behavior, rate limits, and batch operations. This guide doesn't cover single-address checks at registration. Confirm in the documentation whether real-time lookups are supported before building one.

Implementing fallback for invalid emails

When contact verification returns "unknown" for an imported address, proceed with the native Laravel flow and let the bounce webhook handle any failures:

if ($status === 'unknown') {
// Verification service couldn't determine validity
// Send the email and rely on bounce webhooks
$user->sendEmailVerificationNotification();

// Log for monitoring
Log::info('Unknown email status, proceeding with send', [
'email' => $user->email,
'verification_status' => $status
]);
}

The "risky" status indicates the address exists but has quality issues (role-based addresses, disposable domains, or spam complaint history). Accept these with additional monitoring or reject them based on your application's requirements.

Stay below the bounce thresholds with pre-import verification

send.io enforces sender reputation thresholds on hard bounces and complaints. It measures them across the last 24 hours and the last 7 days, as a share of accepted sends, and the limits change with send volume across four tiers:

Send volume

Hard bounce threshold

Complaint threshold

Under 2,000 sends

15 hard bounces (flat cap)

3 complaints (flat cap)

2,000 to 49,999 sends

5%

0.08%

50,000 to 500,000 sends

4%

0.08%

Above 500,000 sends

3%

0.06%

Check the send.io API documentation for the current limits.

An account that exceeds its threshold is suspended, and new send attempts return a 403 sending_suspended error until you pass a manual review. During suspension, send.io holds queued mail, and broadcasts and automations pause. Verifying imported lists before the first send keeps known-invalid addresses out of your sending, which reduces the hard bounces that count toward these thresholds.

Handling bounce events and verification failures

Even with pre-verification, addresses can become invalid between verification and use, and some users never click the verification link. Handle these cases explicitly, or they become silent data quality issues.

Managing expired verification tokens

Laravel's default 60-minute expiration window on verification links balances security against user experience. When a user clicks an expired link, the signed middleware throws an InvalidSignatureException. Catch this in your exception handler:

// app/Exceptions/Handler.php
public function render($request, Throwable $exception)
{
if ($exception instanceof InvalidSignatureException) {
return redirect()
->route('verification.notice')
->with('error', 'This verification link has expired. Request a new one below.');
}

return parent::render($request, $exception);
}

The verification notice view should include a resend form that posts to the verification.resend route you registered earlier.

Update email address and resend verification

Provide a way to update the email address if users made a typo during registration:

Route::post('/email/update-and-resend', function (Request $request) {
$validated = $request->validate([
'email' => 'required|email|unique:users,email,' . $request->user()->id
]);

$user = $request->user();
$user->email = $validated['email'];
$user->email_verified_at = null;
$user->save();

$user->sendEmailVerificationNotification();

return back()->with('message', 'Verification email sent to your new address.');
})->middleware(['auth', 'throttle:6,1']);

This resets the verification timestamp and sends a fresh verification email to the updated address.

Throttling email verification endpoints

The throttle:6,1 middleware on verification endpoints prevents abuse but can frustrate legitimate users who need multiple resends. Track resend attempts per user:

$resendCount = Cache::get("verification_resends:{$user->id}", 0);

if ($resendCount >= 3) {
return back()->withErrors([
'email' => 'Too many verification attempts. Please contact support.'
]);
}

Cache::put("verification_resends:{$user->id}", $resendCount + 1, now()->addHour());

This rate-limiting guard caps resends per user, which limits how much send quota and sender reputation a single account can consume.

Managing hard bounces in verification

When a verification email hard bounces despite pre-verification, update the user record to reflect the delivery failure:

private function handleBounce($payload)
{
if ($payload['bounce']['type'] === 'Permanent') {
$user = User::where('email', $payload['recipient'])->first();

if ($user) {
// Flag the account for review
$user->update([
'email_status' => 'bounced',
'bounce_reason' => $payload['bounce']['message']
]);

// Prevent further sends to this address
$user->notification_channels = [];
$user->save();
}
}
}

This prevents your application from repeatedly attempting to send to addresses that don't exist, which would compound the sender reputation damage.

Test the contact verification import behavior in a sandbox or test environment against a sample list of known valid and invalid addresses before wiring it into your production import job. Check the send.io API documentation for the endpoint and test behavior first, then confirm how each verification status maps to your import handler before real contacts reach it.

FAQs

How do you change the verification link expiration time?

Set the auth.verification.expire configuration value in config/auth.php to your desired expiration time in minutes. The VerifyEmail notification reads this value when it builds the link. The default is 60 minutes, but you can extend it to 1440 (24 hours) or reduce it to 15 minutes depending on your security requirements.

Can you verify emails without sending a verification email?

Yes, for imported contacts. send.io's contact verification assigns a validity status (valid, invalid, risky, or unknown) to each address at import time without sending any email, but it doesn't confirm the user owns the address, so you lose the ownership proof that clicking a verification link provides. For single-address checks at registration, confirm in the send.io API documentation whether real-time lookups are supported.

What happens if a user tries to access protected routes before verifying?

The verified middleware redirects web requests to the verification.notice route with a message prompting them to check their email. API requests receive a 403 JSON response with the message "Your email address is not verified."

How do you test email verification in local development?

Use Laravel's log mail driver to write verification emails to storage/logs/laravel.log, then copy the verification URL from the log entry. Alternatively, use Mailhog or Mailpit to capture emails locally with a web interface.

Should you verify email addresses before sending verification emails?

For per-registration signups, start with the native verification flow. The signed link proves the user owns the address, and the bounce webhooks suppress any hard bounce after the first send. Contact verification is the secondary layer: it runs at import time, so use it when you bulk-import contact lists where invalid addresses are likely. Verifying contacts on import with send.io's contact verification reduces the hard bounces that damage sender reputation. Before adding a single-address lookup to your registration request, confirm in the send.io API documentation whether real-time lookups are supported.

Key terms glossary

MustVerifyEmail contract: Laravel interface requiring four methods that enable email verification behavior on the User model.

verified middleware: Route middleware that blocks access to protected resources until the user's email_verified_at timestamp is non-null.

email_verified_at column: Nullable timestamp field on the users table that tracks verification state (null means unverified).

Hard bounce: Permanent delivery failure indicating the recipient address doesn't exist or the server rejected the message outright.

Contact verification: send.io feature that checks email address validity when contacts are imported and assigns a status of valid, invalid, risky, or unknown before sending.

Webhook signature validation: Verification of a signature header against a hash computed from the raw payload and a shared secret, which confirms the payload came from the expected sender and wasn't tampered with in transit.

Idempotent webhook handler: Event processor that safely handles duplicate webhook deliveries by checking for previously processed message IDs.

Suppression list: Database of email addresses that shouldn't receive sends due to hard bounces, complaints, or unsubscribes, maintained to protect sender reputation.