Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MrMichaelM's avatar

Overriding default email components

Hi, having an issue with overriding default email components in Laravel 6.

I've ran the 'php artisan vendor:publish' so I have access to the vendor files.

I can edit the email.blade in notifications which works fine. However when I edit the blade files in vendor.mail.html or vendor.mail.text the changes never take.

Is there anything specific that needs done to make these override Laravel default or should they just work automatically if they exist?

I've also tried cache clear and view clear.

Any suggestions would be appreciated..

0 likes
4 replies
automica's avatar

can you post the method you are using to send your emails?

MrMichaelM's avatar

I'm not sending the email, it's the built in auth part of Laravel.

I want to override the default emails sent from Laravel i.e Password reset

Specifically I want to edit the header and footer of the message. These can be found in the mail.html and mail.text folders however changing these files after publishing the vendor doesn't do anything.

That said editing them directly in the Laravel package does work -

laravel/framework/src/Illuminate/Mail/resources/views/html

laravel/framework/src/Illuminate/Mail/resources/views/text

On further expection, I override the Notifications/ResetPassword.php class as well, which allows me to edit the contents of the email too but very little has changed here.

 public function toMail($notifiable)
    {
        $tenant = app()->make("Tenant");

        return (new MailMessage)
            ->subject('Reset your password - ' . config('app.name'))
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url($tenant->route('password.reset', [ 'token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset() ], false)))
            ->line('This password reset link will expire in 60 minutes.')
            ->line('If you did not request a password reset, no further action is required.');
    }
MrMichaelM's avatar

The email.blade.php that is created in vendor/mail/notifications/ following the publish artisan command looks like this:

@component('mail::message')
// Other things in here
@endcomponent

The 'mail::message' it is referring to exists also in the vendor however when the email is sent it uses the templates located in the package and not the overrides.

I used the method here to do the override - https://laracasts.com/discuss/channels/general-discussion/laravel-7-how-to-replace-password-reset-mail-template

MrMichaelM's avatar
MrMichaelM
OP
Best Answer
Level 1

Found the issue..

Need to add this to config/mail.php, perhaps not there as I've an older project.


    /*
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    |
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    |
    */
    
    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ]
    ],

Please or to participate in this conversation.