Home Laravel How to Send Mail in PHP Laravel?

How to Send Mail in PHP Laravel?

by Shahriar Sagor
Send Mail in Php Laravel

Today now in this post i will show you How to Send Mail in PHP Laravel? Laravel provide us several way to send to email. We can also use this on core PHP method for send the mail and we can also use some email service providers such as sendmail, smtp, mandrill, mailgun, mail, gmail etc. So here we can choice any one and you set configuration. Laravel provide us Mail facade for mail sending that have also several method for send the email.So now in this example here i am going to show you how to send a emails from gmail account example. Now this example is a very simple you can use as your requirement easily. So It is very simple to configuration with gmail account so at first need to open your .env file and add the bellow gmail configuration.


Now you are totally ready to send the mail for test so at first need create test route for email sending.

Route::get('mail', 'HomeController@mail');

Ok, now need to add mail function in HomeController.php file so add this way :

public function mail()
    $user = User::find(1)->toArray();
    Mail::send('emails.mailExample', $user, function($message) use ($user) {
        $message->subject('E-Mail Example');
    dd('Mail Send Successfully');

So now at last need to create a email template file for send mail so let’s create mailExample.blade.php file in emails folder.

Hello {{ $name }}, I am from Codingspoint.com.

Read Also : Laravel Stripe example by using Laravel Cashier from Scratch

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like