I get this error in the controller. I've already added a use Mail statement before the class declaration but still doesn't work.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Redirect,Response,DB,Config;
use Mail;
class EmailController extends Controller
{
public function sendEmail()
{
$user = auth()->user();
Mail::to($user)->send(new MailNotify($user));
if (Mail::failures()) {
return response()->Fail('error');
}else{
return response()->success('Successfully send in your mail');
}
}
}
Try changing this:
use Mail;
// ...
to this:
use Illuminate\Support\Facades\Mail;
// ...
Also, add this to properly import the other class:
use App\Mail\MailNotify;
Just then you'll be able to do:
Mail::to($user)->send(new MailNotify($user));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With