Laravel 8 Send Email Tutorial

In this tutorial you will learn about the Laravel 8 Send Email Tutorial and its application with practical example.

In this Laravel 8 Send Email Tutorial I will show you how to send mail using gmail smtp server. In this tutorial you will learn to send email using gmail smtp server in laravel application. In this article I will share example to send email in laravel 8 using mailable and mailtrap. We will use Laravel 8 builtin mailable markdown class to send emails. In order to send email using mailtrap we will implement laravel 8 builtin mailable markdown class. In this post I’ll show you how to integrate mailtrap to send email in laravel 8 application.

Install Laravel 8

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

Setup Database Credentials

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.

Make Email Configuration

In this step we will be setting smtp detail for mail configuration in Laravel, We will be using following Gmail SMTP details such as username, password inside the .env file.

Create Mail

Now, lets create a new laravel mailable class using following artisan command:

Once the above command executed, it will create a new laravel mailable class MyTestMail.php in app/Mail/ directory. Open the MyTestMail.php file and put the following code in it.

app/Mail/MyTestMail.php

Create Blade View

In this step, we will create view/blade file to setup email template. Open resources/views/emails/myTestMail.blade.php file, put the following code.

resources/views/emails/myTestMail.blade.php

Add Route

Now, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

In this tutorial we have learn about the Laravel 8 Send Email Tutorial and its application with practical example. I hope you will like this tutorial.