Add laravel mail to your composer.json file

To add Laravel Mail to your composer.json file, you can follow these steps:

  1. Open your composer.json file in a text editor.

  2. Add the following line under the require section:

    "illuminate/mail": "^8.0"

    This will add the Laravel Mail package to your project's dependencies.

  3. Save the changes to your composer.json file.

  4. Run the following command in your terminal to update your project's dependencies:

    composer update

    This will download and install the Laravel Mail package and its dependencies.

  5. Once the installation is complete, you can use the Laravel Mail facade in your Laravel application.

Here's an example of how you can use the Laravel Mail facade:

use Illuminate\Support\Facades\Mail;

Mail::send('emails.welcome', ['user' => $user], function ($message) {
    $message->from('[email protected]', 'Hello');
    $message->to('[email protected]', 'User');
    $message->subject('Welcome!');
});

In this example, we're sending a welcome email to the user using the Mail::send method. The first argument is the view name, the second argument is an array of data to pass to the view, and the third argument is a closure that defines the email message.

Note: Make sure you have the emails directory in your Laravel project's root directory, and that you have created a welcome.blade.php view in that directory.