I am a little confused about whether to use Laravel's Notification or Mailable class. From what I understand, Mailables are used to send only emails whereas Notifications can be used to send emails and sms. In my application, I dont have plans to send sms notifications for now, so I am confused if I should just use the Mailable class in this case. My questions are:
If I am only going to be sending emails notifications, is it better for me to use Mailables instead of Notifications?
If each emails have different html layout, then would Mailable be the better option?
Even if all emails are Notification emails in nature, does it still make sense to send them using Mailables instead of Notifications?
Can someone tell me the main difference between these 2 and how should we decide on which method to choose when sending emails in Laravel 5.3.
From what I understand, Mailables are used to send only emails whereas Notifications can be used to send emails and sms.
Laravel comes with a Mailable class that you can use to send emails effortlessly with. A good example of when to use the Mailable class is when the user registers. Upon registration completion, a welcome email is sent to the user.
Laravel Notify is a package that lets you add custom notifications to your project.
Although it is not in the documentation, as of Laravel 5.3.7, the Notifications mail
channel can work with Mailable
objects in addition to the notification MailMessage
objects.
Therefore, you can create all your emails as Mailable
objects, and if you decide to send them via Notifications, you would just have your toMail()
method return the Mailable
objects you've already made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With