Posts Learn Snippets Categories Tags About
/

Default Email Subject in Laravel Notifications

Learn to name your Laravel notification class property to get a proper email subject as the default value

Created on Jul 01, 2021

8 views

When creating Laravel Notification and you don't specify a subject to the "toMail" method, the default class name will be used as the default email subject. So the CamelCased name of your class will be read by Laravel and it will become the email subject by default.

So if your notification class is like below:
class UserConfirmationEmail extends Notification
{
  // your code here
}

Then the email notification that the user will receive will have the subject of "User Confirmation Email".

Created by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.