How to Send Email in Laravel 9

How to send email in laravel 9.png

Laravel 9 e-mail sending tutorail; on this tutorial we can learn how to send emails in laravel 9 the usage of SMTP drivers like Mailgun, Postmark, Amazon SES and sendemail.

Laravel 9 provide us a mail class for sending emails. So we would really like to show you the way to send emails from localhost the use of mailable in laravel 9 project.

Laravel 9 affords numerous SMTP drivers consisting of Mailgun, Postmark, Amazon SES and sendmail.

This is a simple way to send multiple emails from localhost. It also work on live server.

How to Send Email in Laravel 9

Following steps are required to send emails from localhost in laravel 9 project:

  • Step 1 – Laravel 9 App creating

  • Step 2 – SMTP Configuration in .env file

  • Step 3 – Mailable Class creating

  • Step 4 – Email Send Route creating

  • Step 5 – View files creating

  • Step 6 – Email Controller creating

  • Step 7 – Testing project

Step 1 – Laravel 9 App Creating

First of all we need a fresh project of laravel 9. run the given comman to create a new project:

composer create-project laravel/laravel EmailSend

Step 2 – SMTP Configuration in .env file

Open your project on your favourite code editor and open file .env and replace the given code.

MAIL_USERNAME=enter your email which you want to use for mail sent
MAIL_PASSWORD=enter password of email which you using

If you using Gmail to send a mail then you need to turn of Less Secure in google account setting. Click here to update your setting.


Step 3 – Mailable Class Creating

We need a NotifyMail class which is creating by running given command.


Php artisan make:mail NotifyMail


After creating NotifyMail update with the given code or you can simply write in build() function: 

return $this>view('MailSend');
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class NotifyMail extends Mailable
    use Queueable, SerializesModels;
    public function __construct()




    public function build()

        return $this>view('MailSend');




Step 4 – Email send route creating

In your project directory open routes/web.php file and paste the given code in it.


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\EmailController;
Route::get('emailsend', [EmailController::class, 'index']);


Step 5 – View files creating

So in this we will see how to create view files which are use to send mail. Open resouces/views directory then create a files with name MailSend.blade.php and paste given code in it and save.

<!DOCTYPE html>
<title>How to Send Email in Laravel 9</title>
<h2>TheSkillStock – Email Sending Testing</h2>
<p>How to Send Email in Laravel 9</p>



Step 6 – Email Controller Creating

So the main step in this tutorial is a EmailController which provide functionality to send email to a user. Run the given command to create controller:

php artisan make:controller EmailController

So in your project directory open App/Http/controllers and open EmailController.php and replace with the given code.

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mail;
use App\Mail\NotifyMail;
class EmailController extends Controller

    public function index()


    Mail::to('ReciverEmail')->send(new NotifyMail());//replace and email which going to recive a email with ReciverEmail

     if (Mail::failures()) {

     return response()->Fail('Sorry! Please try again latter');


      return response()->success('Successfully send your mail');




Step 7 – Testing project

So the final step is to test our project by running this command.

php artisan serve

Click here to open your project:

Run project

Thank You For reading this tutorial


About author


Muhammad Zubair

My name is Muhammad Zubair. I'm a full-stack developer. I'm a owner of I love to write tutorials of PHP, Laravel, Html & css, Javascript, Java and much more with examples.


virtual local numbers Mar 18th 2023

virtual phone number in <a href="">portugal</a>

european sailing Mar 20th 2023

<a href="">sailing charter italy | european yachts</a>

eurosegeln com Mar 21st 2023

yacht charter italien <a href="">go now</a>

piterskie zametki Mar 22nd 2023

<a href="">Любовь Толкалина хейтерам «всё, чем вы недовольны — плод вашего видения мира и разума» - срочно</a>

gurava ru Mar 24th 2023

<a href="">недвижимость Борзя сайт Гурава</a>

kolmovo Mar 25th 2023

<a href="">найти работу в великом новгороде свежие вакансии</a>

KellyImmop Apr 3rd 2023

<a href="">Hill's Prescription Diet Digestive Care i/d Stress Chicken Formula Dry Dog Food</a>

Ernestlem Apr 11th 2023

Between us speaking. _ _ _ _ _ _ _ _ _ _ _ <a href=>iherb promotion</a>

Leave a Reply