6

I updated my application from 5 to 5.2. Now when I call Mail::send() it return an exception Class mailer does not exist.

Mail::send('emails.mail', ['data' => $content], function ($m) use ($to, $subject,$toname) {

            $m->to($to, $toname)->subject($subject);


        });

When I open Illuminate\Support\Facades\Mail class there is only one function

protected static function getFacadeAccessor()
{
    return 'mailer';
}

Please help. If anyone have any idea

Vijay Sebastian
  • 1,124
  • 1
  • 12
  • 21

4 Answers4

16

Yes, I found the solution just put Illuminate\Mail\MailServiceProvider::class, in app.php providers

rap-2-h
  • 30,204
  • 37
  • 167
  • 263
Vijay Sebastian
  • 1,124
  • 1
  • 12
  • 21
2

Sometimes php artisan config:clear must be run in order to get rid of that kind of errors ("Class mailer does not exist").

I've migrated my project 1:1 (code, config, vhost) from old laptop to new one (Windows->Ubuntu) and I couldn't run the app without clearing config's cache.

Wirone
  • 3,304
  • 1
  • 29
  • 48
  • 2
    What if running `php artisan config:clear` just repeats the error instead of clearing the config? – movac Apr 30 '20 at 17:27
  • This is an old post but this could help someone, my problemas was a parameter that I was incluiding in EventServiceProvider.php in trying to capture every login event, so the error could just be somwhere where you are not looking! – Gary May 05 '20 at 04:51
2

Check where is you call \Debugbar::enable();, it happens when you enable debugbar in register method of service provider.

Dobrik
  • 21
  • 1
0

For me I had to delete the files in bootstrap/cache and run composer update.

cbaigorri
  • 2,467
  • 25
  • 26