我的.env文件是:
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);
}
}
位指示:
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>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>
这是我的档案: 我在尝试发送电子邮件时遇到了连续错误。
缺少Illuminate \ Support \ Manager :: createDriver()的参数1,在第89行的/home/robustit/public_html/nic-website/vendor/laravel/framework/src/Illuminate/Support/Manager.php中调用,定义
答案 0 :(得分:-1)
到目前为止,我遇到过这个问题。
你想要的是检查.env文件并确保数据库参数正确,但你也想要这些:
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
出于某种原因,我得到了这些空字段。然后它对我有用!