Php Laravel 5通过mandrill错误发送电子邮件
My mail.php`Php Laravel 5通过mandrill错误发送电子邮件,php,email,laravel,laravel-5,mandrill,Php,Email,Laravel,Laravel 5,Mandrill,My mail.php` 'driver' => 'mandrill', 'host' => 'smtp.mandrillapp.com', 'port' => 587, 'from' => ['address' => 'mohaimin.moin10011@gmail.com', 'name' => null], 'encryption' => 'tls', 'username' => 'mohaimin.moin10011@gmail.com'
'driver' => 'mandrill',
'host' => 'smtp.mandrillapp.com',
'port' => 587,
'from' => ['address' => 'mohaimin.moin10011@gmail.com', 'name' => null],
'encryption' => 'tls',
'username' => 'mohaimin.moin10011@gmail.com',
'password' => 'mandrill-api-key',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,`
在我的控制器中,将一些信息保存在某个数据库表中后,存储方法代码为code
public function store()
{
$message = "";
$qccheck = new Qccheck();
$qccheck->DateOfCheck = Input::get('DateOfCheck');
$qccheck->ReferenceNo = Input::get('ReferenceNo');
$qccheck->Comment = Input::get('Comment');
$qccheck->CheckById = Input::get('CheckById');
$qccheck->ExpectedValue = Input::get('ExpectedValue');
$response = $qccheck-> save();
$checkDetails = Input::get('qccheckdetails');
$checkDetailsqty = Input::get('qccheckdetailsqty');
$contactName = 'Moin';//Input::get('name');
$contactEmail = 'mohaimin.moin10011@gmail.com';//Input::get('email');
$contactMessage = 'Quality Check';//Input::get('message');
$DateOfCheck = Input::get('DateOfCheck');
$Formatdate = date("d-m-Y", strtotime($DateOfCheck));
$ReferenceNo = Input::get('ReferenceNo');
$Comment = Input::get('Comment');
$b = Input::get('qccheckdetailsqty');
$data = array(
'name'=>$contactName,
'email'=>$contactEmail,
'messageObj'=>$contactMessage,
'checkdate'=>$Formatdate,
'refno'=>$ReferenceNo,
'ct'=>$Comment,
'b'=> Input::get('qccheckdetailsqty')
Mail::send('emails.email' ,$data, function($message) use ($contactEmail, $contactName)
{
$message->from($contactEmail, $contactName);
$message->to('esharif21@gmail.com')->subject('Mail send cheque');
});
if(count(Mail::failures()) > 0){
$message = "Email not send";
}
else
{
$message = "Email Sent!";
}
}
return $message;
}
我的路线是
Route::post('/storeQccheck', 'QccheckController@store');
我的emails.email视图是
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<div>
Checking date {!! $checkdate !!} and the Reference is {!! $refno !!} and
Comment {!! $ct !!}.
</div>
</body>
</html>
正在检查日期{!!$checkdate!!},引用为{!!$refno!!},并且
注释{!!$ct!!}。
但它没有发送电子邮件,而是在RouteCollection.php第207行中显示了
方法NotAllowedHttpException:
。我的代码中有什么错误,哪里有错误。但如何调用此操作?我的电子邮件方法是controller中的store方法,保存项目后,此邮件方法被调用。此外,如果我使用Mail::raw只是为了发送一个字符串进行测试,那么就可以了。您是将此路由用作表单操作还是在AJAX请求中使用?MethodNotAllowedHttpException通常在您对路由使用不正确的方法时发生。您可能是通过GET请求浏览器导航此url,但路由是为POST请求定义的。请粘贴调用此操作的代码-我猜您使用的是表单。