Hey there.
Today I'm gonna show you how to send email notifications to any user email.
Normally, when you send email notifications in laravel, use the function notify
, included in the main User model, like this:
<?php
$user->notify(new FormContact($form));
So, how can we send an email notification if we don't have the user registered?
Imagine that you have a typical contact form inside your website, normally you send an email to your main account (which may be registered), and also you would like to send a Thank you email to the user that sent the form.
So to do that in Laravel, we only have to notify the user with Notification class, like this:
<?php
Notification::route('mail', '[email protected]')
->notify(new FormContact($form));
Simple and useful trick.
Thank you!
Comments (0)