试图使用Laravel发送电子邮件,但不断收到405错误和显示的欢呼页面:
* @param array $others
* @return void
*
* @throws 'Symfony'Component'HttpKernel'Exception'MethodNotAllowedHttpException
*/
protected function methodNotAllowed(array $others)
{
throw new MethodNotAllowedHttpException($others);
}
代码为:
{{ Form::open(array('url' => 'admin/newemail')) }}
// form items
{{ Form::close() }}
路线是:
Route::get('admin/newemail', function()
{
$email = 'email@hotmail.com';
$data = array('s' => Input::get('email-heading'));
Mail::send('emails.wereback', $data, function($message) use ($email){
// $message details
});
});
然而,如果我直接转到url admin/newemail,它可以正常工作。
有什么帮助吗?
默认情况下,Form
帮助程序将生成一个使用POST方法的html表单。如果需要使用不同的方法,可以指定该方法:
{{ Form::open(array('url' => 'admin/newemail', 'method' => 'GET')) }}
或者,您也可以更改路由以匹配POST请求:
Route::post('admin/newemail', function()
{
// [...]
});