Send Email In Laravel

WebSolutionStuff | Sep-02-2020 | Categories : Laravel PHP

In this article, we will see how to send emails in laravel 6 and laravel 7. In this post, we will show how to send emails using SMTP in laravel. email is a very basic and important feature in the web development field and it is necessary for all clients.

Sending email doesn't have to be complicated. Laravel provides a clean, simple email API powered by the popular Symfony Mailer component. Laravel's email services may be configured via your application's config/mail.php configuration file.

So, let's see how to send mail in laravel 6/7.

Laravel 6/7 Send Mail Example

Step 1: Setup Mail Configuration
Step 2: Create Mail
Step 3: Create Blade File
Step 4: Create Route
Step 5: Create Controller



Step 1: Setup Mail Configuration

First of all, we need to set the configuration in the .env file for sending mail, here we use SMTP. So, set the configuration as below.



Step 2: Create Mail Using Artisan Command

Laravel provides an inbuilt mail class for sending mail. So, we will create testmail class for the same.

php artisan make:mail TestMail

Now you can find the file in this location app/Mail/TestMail.php

Add the below code for viewing.


namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class TestMail extends Mailable
    use Queueable, SerializesModels;

     * Create a new message instance.
     * @return void
    public function __construct()

     * Build the message.
     * @return $this
    public function build()
        return $this->view('mail.Test_mail');



Step 3: Create Blade File

Now, I have created a Test_mail.blade.php file and we will add some text dummy text for email test purposes.


Hi <br/>
This is Test Mail From Websolutionstuff. <br />
Thank you !!


Step 4: Create Route

Now, create a route for testing send mail.

Route::get('test_mail','[email protected]');


Step 5: Create Controller

 Now, we will create UserController and add the below code.

public function testMail()
	$mail = 'websolutionstuff';
	Mail::to($mail)->send(new TestMail);

	dd('Mail Send Successfully !!');


And after that, you get output like the below screen print.



You might also like:

Recommended Post

Featured Post

Follow us
facebooklogo github instagram twitter

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock or some other adblocking software which is preventing the page from fully loading.

We need money to operate the site, and almost all of it comes from our online advertising.

Please add websolutionstuff to your ad blocking whitelist or disable your adblocking software.