Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel use default email template

Tags:

php

email

laravel

how can I use default email template Laravel in my function Mail send?

Mail::send('default template?', $data, function($message) use($data) {
    $message->to($data['email']);
    $message->subject('New email!!!');
});

Do I need to create a new template? By why I can't use default email template? I can edit default template in resources/vendor/mail/html . Please help me use default email template.

like image 483
Jadasdas Avatar asked Sep 15 '25 02:09

Jadasdas


1 Answers

I don't think the template you are referencing is a Laravel mail template. There are a few ways you can use Laravel's default mail templates. You can create a mailable class and build the email up using Laravel's pre-built email markdown, or you can create another blade template which you reference like any other blade template within Laravel.

Steps:

  1. Create a new blade file in resources/view => mail.default.blade.php
  2. Add HTML template code for email
  3. Reference like so
Mail::send('mail.default', $data, function($message) use($data) {
    $message->to($data['email']);
    $message->subject('New email!!!');
});

OR

In Laravel, each type of email sent by your application is represented as a "mailable" class. These classes are stored in the app/Mail directory. Don't worry if you don't see this directory in your application, since it will be generated for you when you create your first mailable class using the make:mail command:

php artisan make:mail OrderShipped

Markdown mailable messages allow you to take advantage of the pre-built templates and components of mail notifications in your mailables. Since the messages are written in Markdown, Laravel is able to render beautiful, responsive HTML templates for the messages while also automatically generating a plain-text counterpart.

like image 80
Sam Killen Avatar answered Sep 17 '25 16:09

Sam Killen