Laravel 7/6 Send Email Using Mailable Class Tutorial

In this tutorial you will learn about the Laravel 7/6 Send Email Using Mailable Class Tutorial and its application with practical example.

In this Laravel 7 send email example using mailable tutorial I’ll show you how to send email in laravel using a mailable class with example. In this step by step tutorial I’ll guide you through how to send email in laravel using SMTP driver. Laravel provides an API with driver support for SMTP, SendMail, Mailgun, Sendgrid, Mandrill, Amazon SES, SpartPost, etc. In this tutorial we will use simple example of mailable class to send email in laravel application.

Laravel Send Email Using Mailable Class Example

  • Install laravel Fresh Setup
  • Configuration SMTP in .env
  • Mailable Class
  • Create Route & Blade View
  • Create Controller & Method
  • Run Development Server

Install Laravel 8

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Configure Database In .env file

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Configuration SMTP in .env

Now we will configure SMTP credentials in the .env file. Let’s open .env file.

.env

Mailable Class

Now, create a mailable class for sending emails, use the following command :

Create Route & Blade View

Now, we need to create a route to send email, open your routes/web.php input the below route :

Next, we will create an email blade view file in views folder of view. Go to the resources/views/emails and create a view file name email.blade.php. Put bellow code:

Create Controller & Method

In this step we will create a new controller EmailController with one method to send email. Open your terminal and run following command to create controller:

Now open the controller file and put the following code in it:

Run Development Server

In this step, we will start the development server using following command:

Now, visit the following link to send email:

In this tutorial we have learn about the Laravel 7/6 Send Email Using Mailable Class Tutorial and its application with practical example. I hope you will like this tutorial.