Mail::send() not working in Laravel 5

Mail is an alias inside the global namespace. When you want to reference it from inside a namespace (like App\Http\Controllers in your case) you have to either:

Prepend a backslash:

\Mail::send(...)

Or add a use statement before your class declaration:

namespace App\Http\Controllers;

use Mail;  // <<<<

class MyController extends Controller {

The same goes for the other facades you use. Like Session and Redirect.


Another way is to use Mail facade

use Illuminate\Support\Facades\Mail;

In your controller


In Laravel 5.8 I solved it by also adding this in the controller :

THIS:

use App\Mail\<<THE_NAME_OF_YOUR_MAIL_CLASS>>;
use Illuminate\Support\Facades\Mail;

INSTEAD OF:

use Mail;

Tags:

Php

Email

Laravel