How To Send Email Using Mailtrap In Laravel 7

How To Send Email Using Mailtrap In Laravel 7

Welcome to you In this article. Today, we will discuss you how to Send Email using mailtrap in laravel 7. we are using SMTP to send email in this article. laravel provides a mailtrap package library so we can use that and easily send the mail.

so you can see our laravel 7 email sending tutorial.

Overview

Step 1: Install Laravel 7

Step 2: Create Nailtrap Account

Step 3: Email Configuration

Step 4: Create a Mailable class

Step 5: Create Blade Files

Step 6: Create Route in web.php file

Step 7: Run Our Laravel Application

Step 1: Install Laravel 7

We are going to install laravel 7, so first open the command prompt or terminal and go to go to xampp htdocs folder directory using the command prompt. after then run the below command.

Step 2: Create Nailtrap Account
In this step, you go to the mailtrap.io official website and create the account and get user id and user email.

Step 3: Email Configuration

After the complete installation of laravel. we have to mail configuration. now we will open the .env file and define the mail_driver, mail_host, mail_port, mail_username, mail_password and mail_encryption in the .env file. See below changes in a .env file.

Step 4: Create a Mailable class

We will create a mail class using the below command. Now, if you want to pass the object for the view then you can write and pass the object in this file. so here we pass the student_detail in the below file.
.

MySendMail.php

 

Step 5: Create Blade Files

First, we will create the new directory “resources/views/emails” and that directory in creating a “resources/views/emails/mySendMail.blade.php” file.

mySendMail.blade.php

Step 6: Create Route in web.php file

We have to need put the below route in routes/web.php file.

StudentController.php

Step 7: Run Our Laravel Application
We can start the server and run this example using the below command.

Now we will run our example using the below Url in the browser.

Please follow and like us: