A new link is on its way.
``` We'd also show which address the link went to, with a way to change it. Most "I never got the email" tickets are typos. ## Customising the verification email You can change both the message and the URL from a service provider's `boot()` method: ```php use Illuminate\Auth\Notifications\VerifyEmail; use Illuminate\Notifications\Messages\MailMessage; VerifyEmail::toMailUsing(function (object $notifiable, string $url) { return (new MailMessage) ->subject('Confirm your email for '.config('app.name')) ->line('Click the button below to finish setting up your account.') ->action('Confirm email', $url); }); ``` `VerifyEmail::createUrlUsing()` replaces the link itself, which is handy when a separate frontend handles the click. To change how long links last, add a `verification.expire` value (in minutes) to `config/auth.php`. By default the notification goes out synchronously, so a slow mail server makes registration slow. We'd queue it. Create a notification that extends `VerifyEmail`, implements `ShouldQueue` and uses the `Queueable` trait, then override `sendEmailVerificationNotification()` on your user model so it sends that class instead. Don't forget to run a queue worker. ## When a user changes their email A verified account that switches to a new address is unverified again. Handle that where the profile gets updated, and put it in a service rather than the controller: ```php $user->fill($data); if ($user->isDirty('email')) { $user->email_verified_at = null; } $user->save(); if ($user->wasChanged('email') && $user instanceof MustVerifyEmail) { $user->sendEmailVerificationNotification(); } ``` Since the link hash is built from the current email, any link sent to the old address is now useless. ## Edge cases to plan for | Situation | What happens | What to do | | --- | --- | --- | | User opens the link on another device | The route requires login, so they are sent to the login page first | After login they are redirected back to the link and verified | | Link has expired | The `signed` middleware returns a 403 | Make the resend button easy to find | | Link clicked twice | Already verified; the user is simply redirected | Nothing | | User was invited by an admin | They proved ownership by opening the invite link | Set `email_verified_at` when they accept, see [user invitations with signed URLs](/blog/laravel-user-invitations-signed-urls.html) | | Accounts created by seeders | No email is sent | Set `email_verified_at` in the seeder | In local development, set `MAIL_MAILER=log` and copy the link out of `storage/logs/laravel.log`. ## Frequently asked questions ### Why is Laravel not sending the verification email? Usually the user model doesn't implement `MustVerifyEmail`, so the listener skips it. After that, check your mail settings. If you queued the notification, make sure a queue worker is running. ### How long is a Laravel email verification link valid? Sixty minutes by default. You can change it with `verification.expire` in `config/auth.php`. Once it has expired, the user requests a new link from the notice page. ### Can users log in before verifying their email? Yes. Verification doesn't block login. It blocks the routes you protect with the `verified` middleware, and that's exactly what lets unverified users reach the resend page. ### Should I block login until the email is verified? We wouldn't. Letting users in and gating the important routes gives them a clear next step. If signup abuse is the worry, combine verification with [rate limiting on login](/blog/laravel-login-rate-limiting.html) and a rate limit on your registration route. ## Email verification in SaaS Laravel In the SaaS Laravel kits, most of this is already in place. They enable `Features::emailVerification()` and include a Verify Email page in Vue, React and Svelte with resend and logout buttons. The app's module routes use `['auth', 'verified']`. One catch: `App\Models\User` ships **without** `MustVerifyEmail` (the import is commented out), so verification isn't enforced until you add the interface. The profile settings page resets `email_verified_at` when the email changes and offers a resend link. Seeded users, and invited users who accept, are marked as verified, and each tenant domain can turn verification off. The details are in [email verification in the authentication docs](/docs/core/authentication.html#email-verification).