3

You can send notifications via email like this in Laravel...

<?php

public function toMail($notifiable)
{
    $url = url('/invoice/' . $this->invoice->id);

    return (new MailMessage)
        ->greeting('Hello!')
        ->line('One of your invoices has been paid!')
        ->action('View Invoice', $url)
        ->line('Thank you for using our application!');
}

However, is it a good approach (in software design) to use this feature to send verification emails upon user registration?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Sina Miandashti
  • 2,087
  • 1
  • 26
  • 40
  • Why wouldn't it be? – Jerodev Jun 14 '17 at 10:51
  • Although, sending mail is possible. But In my opinion, Notifications should be used for applications internals / via application defined user interface. I rarely regard email received from system as notification. – Nauman Zafar Jun 14 '17 at 10:57

2 Answers2

1

yes, it is a fast way to send notification, we register a greeting, a line of text, a call to action, and then another line of text. These methods provided by the MailMessage object make it simple and fast to format small transactional emails. The mail channel will then translate the message components into a nice, responsive HTML email template with a plain-text counterpart.

you can also formatting the notification in better way for example:

  • Error Messages
  • Customizing The Recipient
  • Customizing The Subject
  • Customizing The Templates

reference Laravel Reference

0

Laravel Notifications is an all new feature coming to Laravel 5.3 that allows you to make quick notification updates through services like Slack, SMS, Email, and more.

This is great. Notifications are so simple and robust, you may no longer find yourself needing to use any other notification tool (mail, Slack SDK directly, etc.)—especially when you see how many custom notification channels the community has created. It's bonkers.

As always, with great power comes great responsibility; make sure you're being careful with your users' time and attention and you don't go overboard with the notifications.

So, go forth. Notify.

Bilal Ahmed
  • 4,005
  • 3
  • 22
  • 42