在laravel发送邮件时,为Illuminate\Support\Manager :: createDriver()缺少参数1 [英] Missing argument 1 for Illuminate\Support\Manager::createDriver() while sending mail in laravel
问题描述
我的.env文件是:
MAIL_DRIVER = mail
MAIL_HOST = smtp.mandrillapp.com
MAIL_PORT = 587
MAIL_USERNAME=sabin.maharjan456@gmail.com
MAIL_PASSWORD = *************************** *
Mailer.php
<?php命名空间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);
});
返回邮件已发送;
}
public function welcome($ formData)
{
$ subject =用户消息已到!
$ 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);
}
查看文件:
<!DOCTYPE html>
< html lang =en-US>
< head>
< meta charset =utf-8>
< / head>
< body>
< h2>用户消息< / h2>
< p>< b>电子邮件地址:< / b> {{$ email}}< / p>
< h4>用户名:{{$ name}}< / h4>
< p>电话号码:{{$ mobile}}< / p>
< p>消息:{{$ bodymessage}}< / p>
< / body>
< / html>
这是我的文件:
i尝试发送电子邮件时会发生连续的错误。 p>
在/ home / robustit / public_html / nic-website / vendor / laravel / framework / src中调用的Illuminate\Support\Manager :: createDriver()的缺少参数1 /Illuminate/Support/Manager.php在第89行,并定义
到目前为止,我一直有问题。
您想要的是检查.env文件,并确保您的数据库参数正确,但您也希望这些:
CACHE_DRIVER = file
SESSION_DRIVER = file
QUEUE_DRIVER = sync
由于某些原因,我得到了这些空的领域。然后它为我工作!
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
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!
这篇关于在laravel发送邮件时,为Illuminate\Support\Manager :: createDriver()缺少参数1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!