Custom verification email notification, Laravel 5.8
Professionalism means going the extra mile in making a difference. Have you ever longed to change the default verification email but don’t know how? In this post, I explained how you can achieve that.
While there are several ways one can achieve this goal, I think Stefan Bauer twitted a more elegant way to achieve our goal. Unlike twits, I aim to go into details.
Step 1: Create a mailable
php artisan make:mail EmailVerification --markdown=emails.verify-email
After running the above command, we get a mailable object in our Mail folder.
And also a markdown we can customize to meet our brand taste.
Now, how do we tell Laravel to use our custom email template instead of its default template? We plug it in from notification callbacks.
Step 2: Tap into the AppServiceProvider hooks.
And swap in your mailable inside the boot method.
* Bootstrap any application services.
* @return void
public function boot()
// Override the email notification for verifying email
$verifyUrl = URL::temporarySignedRoute(
['id' => $notifiable->getKey()]
return new EmailVerification($verifyUrl, $notifiable);
Notice I passed in both $verifyUrl and $notifiable to our EmailVerification mailable that means we have to add both parameters to EmailVerification’s constructor.
* Create a new message instance.
* @return void
public function __construct($url,$user)
$this->verifyUrl = $url;
$this->user = $user;
It all makes sense now, our $notifiable was a user object. So we now have the recipient address and other vital info we may intend to use in our custom verify-email template.
That’s all to it!
Now I dub thee with two-star in commanding Laravel custom email notification.