Search code examples
phplaravellaravel-mail

I am getting this error while implementing Mail in Laravel 5.5---->Missing argument 1 for Illuminate\Support\Manager::createDriver()


Error - Missing argument 1 for Illuminate\Support\Manager::createDriver()

My env file-

MAIL_DRIVER=smtp
MAIL_HOST=smtp.****.com
MAIL_PORT=587
MAIL_USERNAME=info@*****.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls

All the keys in mail.php of config folder are correct.

My controller function looks like this

function send(Request $request)
    {
        $this->validate($request,[
            'name'=>'required',
            'email'=>'required|email',
            'subject'=>'required',
            'message'=>'min:10'
        ]);

        $data=array(
            'name'=>$request->name,
            'email'=>$request->email,
            'subject'=>$request->subject,
            'bodyMessage'=>$request->message
        );
        Mail::send('mail.admin',$data,function($message) use ($data)
        {
            $message->from($data['email']);
            $message->to($data['info@****.com']);
            $message->subject($data['subject']);
        });
    }

What mistake am i making here?

Here is my mail.php file

<?php
return [ 
    'driver' => env('MAIL_DRIVER', 'smtp'),  
    'host' => env('MAIL_HOST', 'smtp.****.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],   
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),  
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'), 
    'sendmail' => '/usr/sbin/sendmail -bs', 'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Solution

  • I replaced all the settings and codes with my own codes and the email was sent correctly. I suggest removing the composer.lock file and remove the vendor directory and run the composer install again. Maybe the complete package is not installed.