Mail Notification — Laravel

Jaouad Ballat
Aug 26, 2017 · 2 min read

Most of the mail that’s sent from web apps are really has the purpose of notifying users that a particular action has happened.

Laravel 5.3 included a new concept in laravel called notifications.

A notification is a PHP class that represents a single communication that you might want to send to your users.

So let’s create our notification.

create notification

there is a via methode that allow us to define for a given user wich notification channel to use, in our case we’re going to use mail notification

App\Notifications\NewUser

you can customize that app name in the same key of config\app.php

config\app.php

Any model that imports the Laravel\Notifications\Notifiable trait has a notify() method that can be passed a notification, which will looks like

app\Http\Controller\Auth\RegisterController.php

if you want to modify the templates, publish them and edit to your content

php artisan vendor:publish

you can also change the style of default template to be an “error” message, just add a call to the error() methode to change the primary button color to red.

mailtrap.io

The notification system makes it easy to build a single notification that can be delivered in many different media — from email to sms to physical postcards.

)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade