Search code examples
phpsmtplaravel-5.3

How to configure Smtp based Email setup in Luman laravel?


Hi am new to luman laravel framework.I have doubt,How to configure Smtp based Email setup in Luman laravel?.Actually i did something based on some online tutorial but am not sure its correct or not.

My .end file setup

 MAIL_DRIVER=smtp
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=465
    [email protected]
    MAIL_PASSWORD=example
    MAIL_ENCRYPTION=ssl

my mail controller

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Mail;
use Illuminate\Mail\Mailer;

use Illuminate\Http\Request;

class mailcontroller extends Controller {
    public function mail()
    {


 Mail::raw('Text', function ($message)
 {
            $message->to('[email protected]');
 });


    }

}

my routes.php file

 $app->post('mail','mailcontroller@mail');

But i got error like:


Fatal error: Class 'Illuminate\Mail\MailServiceProvider' not found in /var/www/io.tachyloans.com/public_html/vendor/laravel/lumen-framework/src/Application.php on line 163

What i did wrong, please help me or prefer any good tutorial for this problem.Thanks in advance.


Solution

  • Did you? Include the Mail libs:

    composer require illuminate\mail
    

    uncomment lines in bootstrap/app.php

    $app->register('App\Providers\AppServiceProvider'); 
    $app->withFacades();