Send Email In Laravel

WebSolutionStuff | Sep-02-2020 | Categories : Laravel

Hello Guys,

Today i will give you demo how to send email in laravel, in this post we will show how to send email using smtp in laravel, email is very basic and most important feature in web development field and it is neccesory for all client.

So, in this tutorial i will give you information about send mail in laravel. So, follow below steps.

Read Also : REST API In Laravel


Step 1: Set Configuration

First of all we need to set configuration in .env file for sending mail, here we are using smtp mailtrape so set according port also as below.



Step 2 : Create Mail Using Artisan Command

Laravel provide readymate mail class for sending mail so, we need to create testmail class for same,

php artisan make:mail TestMail

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

add below code for view.


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 Test_mail.blade.php file in this path view/mail/Test_mail.blade.php , we need to add some text dummy text for email test purpose.

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


Step 4 : Create Route

Now, Create route for testing send mail

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


Step 5 : Create Controller

 Now create UserController and add below code.

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

	dd('Mail Send Successfully !!');


And after that you get output like below screen print.



Recommended Post
Featured Post