Laravel - Email Verification - Verification Email Customization
Although the default email verification notification should satisfy the requirements of most applications, Laravel allows you to customize how the email verification mail message is constructed.
To get started, pass a closure to the toMailUsing
method provided by the Illuminate\Auth\Notifications\VerifyEmail
notification. The closure will receive the notifiable model instance that is receiving the notification as well as the signed email verification URL that the user must visit to verify their email address. The closure should return an instance of Illuminate\Notifications\Messages\MailMessage
. Typically, you should call the toMailUsing
method from the boot
method of your application's App\Providers\AuthServiceProvider
class:
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Notifications\Messages\MailMessage;
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
// ...
VerifyEmail::toMailUsing(function ($notifiable, $url) {
return (new MailMessage)
->subject('Verify Email Address')
->line('Click the button below to verify your email address.')
->action('Verify Email Address', $url);
});
}
To learn more about mail notifications, please consult the mail notification documentation.