Create new email laravel 5.4

Here's a step-by-step guide to create a new email in Laravel 5.4:

Step 1: Create a new email template

In Laravel 5.4, email templates are stored in the resources/views/emails directory. Create a new file called example.blade.php in this directory:

// resources/views/emails/example.blade.php

<h1>Email Example</h1>

<p>Hello, {{ $name }}!</p>

<p>This is an example email sent using Laravel.</p>

Step 2: Create a new email class

In Laravel 5.4, email classes are stored in the app/Mail directory. Create a new file called ExampleEmail.php in this directory:

// app/Mail/ExampleEmail.php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ExampleEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function build()
    {
        return $this->view('emails.example');
    }
}

Step 3: Define the email in the Mail facade

In the Mail facade, define the email as a new instance of the ExampleEmail class:

// app/Providers/Mail.php

namespace App\Providers;

use Illuminate\Support\Facades\Mail;
use App\Mail\ExampleEmail;

class Mail extends Illuminate\Support\Facades\Mail
{
    public function sendExampleEmail($name)
    {
        Mail::to($name)->send(new ExampleEmail($name));
    }
}

Step 4: Send the email

To send the email, you can use the Mail facade:

// example usage

Mail::sendExampleEmail('John Doe');

This will send an email to John Doe using the ExampleEmail class and the example.blade.php template.

That's it! You've created a new email in Laravel 5.4.