laravelemaillaravel-7

Did I solve my "Target class [mail.manager] does not exist." issue?


Just upgraded from Laravel 6 to 7, and had the error response above when submitting a contact form. I eventually found a solution that seems to work and I am submitting here to help out the next guy.

In the terminal run:

composer require illuminate/mail 

Add the following to the top of the controller file (app/Http/Controllers/Main.php in my case):

use \Illuminate\Support\Facades\Mail;

Add this to bootstrap/app.php:

$app->register(Illuminate\Mail\MailServiceProvider::class); 

Save and test, and it worked localhost.

If the above does not work for you, there are some other possible issues and solutions available at this link, where I must give credit to vipindasks.

https://laracasts.com/discuss/channels/lumen/lumen-52-mail-not-working

Since I am suppose to ask a question:

Do you see any problems with this solution even though the site and mailer is working now?


Solution

  • You are simply missing a backslash. This tells the autoloader that the file you are looking for is not in the namespace your controller resides in :

    $app->register(\Illuminate\Mail\MailServiceProvider::class);