我在Laravel 5.5中实现Mail时收到此错误----> Illuminate \ Support \ Manager :: createDriver()缺少参数1

时间:2018-05-14 18:05:15

标签: php laravel laravel-mail

错误 - 缺少Illuminate \ Support \ Manager :: createDriver()

的参数1

我的环境文件 -

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

config文件夹的mail.php中的所有键都是正确的。

我的控制器功能如下所示

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']);
        });
    }

我在这里犯了什么错误?

这是我的mail.php文件

<?php
return [ 
    'driver' => env('MAIL_DRIVER', 'smtp'),  
    'host' => env('MAIL_HOST', 'smtp.****.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
        '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'),
        ],
    ],
];

1 个答案:

答案 0 :(得分:0)

我用自己的代码替换了所有设置和代码,并且电子邮件已正确发送。我建议删除composer.lock文件并删除vendor目录并再次运行composer install。也许没有安装完整的包。