Laravel 8 Send Mail using Gmail SMTP Server

In this tutorial you will learn about the Laravel 8 Send Mail using Gmail SMTP Server and its application with practical example.

In this Laravel 8 Send Mail using Gmail SMTP Server 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.

Step 1: Make Email Configuration

Step 2: 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

Step 3: 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

Step 4: 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 Mail using Gmail SMTP Server and its application with practical example. I hope you will like this tutorial.