Missing argument 1 for Illuminate\Support\Manager::createDriver() while sending mail in laravel

空扰寡人 提交于 2019-12-23 09:52:34

问题


my .env file is:

MAIL_DRIVER=mail
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=sabin.maharjan456@gmail.com
MAIL_PASSWORD=****************************

Mailer.php

  <?php namespace App\Http\Controllers;

class Mailer{
    public function sendTo($email, $subject, $view, $data = array())
    {
        \Mail::queue($view, $data, function($message) use($email, $subject)
        {
            $message->to($email)->subject($subject);
        });
        return "Mail has been sent";

    }

    public function welcome($formData)
    {
        $subject = "User Message was arrived !";
        $data['name'] = $formData['name'];
        $data['email'] = $formData['email'];
        $data['mobile'] = $formData['mobile'];
        $data['subject'] = $formData['subject'];
        $data['bodymessage'] = $formData['message'];
        $view = 'emails.welcome';
        return $this->sendTo(['sabin.maharjan456@gmail.com'],$subject,$view,$data);
    }
}

contoller:

 public function postContactFormRequest(CreateContactFormRequest $request,Mailer $mailer)
{

    $formData = $request->all();

    $this->mailer->welcome($formData);

  }

view file:

  <!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="utf-8">
</head>
<body>
<h2>User Message</h2>
<p><b>Email Address:</b> {{ $email }}</p>
<h4>User Name : {{ $name }}</h4>
<p> Phone Number :{{ $mobile}}</p>
<p>Message :{{ $bodymessage }} </p>
</body>
</html>

this is my file: i get a continious error while trying to send email.

Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in /home/robustit/public_html/nic-website/vendor/laravel/framework/src/Illuminate/Support/Manager.php on line 89 and defined


回答1:


I have had issues with this until now.

What you want is to check your .env file and make sure your database parameters are right, but also you want these:

CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync

For some reason I got these to have empty fields. And then it worked for me!



来源:https://stackoverflow.com/questions/33626656/missing-argument-1-for-illuminate-support-managercreatedriver-while-sending

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!