Email configuration with Laravel

Last Updated: December 3, 2017

In this article we will see how you can configure Laravel to send email

I am going to use Free account to test the Email

First thing I am going to add SMTP details to .env file


Then you can create controller to test the email

 php artisan make:controller TestEmailController 

Now you can create the send action and add the following code to send test email

public function send(){

      $data = array('key'=>"Value");
      Mail::send(['text'=>'mails.welcome'], $data, function($message) {
         $message->to('', 'Developer')->subject
            ('Laravel Basic Testing Mail');
      echo "Basic Email Sent. Check your inbox.";

Now I am going to create the route for the controller action. In your route\web.php file, add the following line

Route::get('sendemail', 'TestEmailController@send');

Finally you can create the view for the email body
create welcome.blade.php file inside the views\mails folder and put some text in this file

Now you can test the URL http://localhost/user/public/sendemail
You can see the email in

Laravel Email