1
votes

I'm trying to send an email with Laravel (5.4) but still getting this error:

InvalidArgumentException in FileViewFinder.php line 137:
View [mails.forgot] not found.


at FileViewFinder->findInPaths('mails.forgot', array('{my app dir}/resources/views'))
in FileViewFinder.php line 79
at FileViewFinder->find('mails.forgot')
in Factory.php line 128
at Factory->make('mails.forgot', array('emailAddress' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message)))
in Mailer.php line 286

Added the file in resources/views/mails/forgot.blade.php

In the controller:

Mail::to('[email protected]')->send(new ForgotEmail());

In the mail file (Mail/ForgotEmail.php) I call:

return $this->view('mails.forgot');

For the rest of my app views are working correctly.

2
Have you ran composer dump-autoload to see if this helps?Adam
Can you manually view mails.forget, like in a Route, such as Route::get("/test", function(){ return view("mails.forgot"); });, followed by navigating to myapp.com/testTim Lewis
dump-autoload didn't help.. @TimLewis Nice tip, that gives me the same error.. so it seems the reason is not the mailable.Dennis
My routing normally looks like this: Route::post('register/confirm', 'UserController@sendConfirmationEmail');Dennis
Yup; Routing should use Controller methods, but for quick reference you can use a function to mimic one. And yeah, if you can't return it manually, there's something else up, though, at a glance, I can't see it. mails.forgot seems to be the right key to access it...Tim Lewis

2 Answers

0
votes

Clean Laravels caché by issuing either php artisan cache:clear or php artisan config:cache see if that works...

0
votes

On my specific case, the my template filename was user.new.blade.php

It would not work. I renamed it to usernew.blade.php and now it works. Seems like there cannot be extra dots in the filename