2015-01-31 58 views
0

我試圖用Laravel框架設置我的郵件。我設置了一個非常基本的示例來發送測試郵件,只是爲了驗證所有工作是否應該如此。雖然,我無法讓它工作,但它會產生如下所示的錯誤。請注意,我在配置文件中使用了一個工作郵件配置,這是我之前使用過的,這導致我相信它與我在laravel框架內設置事物有關。用Laravel發送基本郵件

我感謝任何幫助,提前致謝!

查看:

<form action="mailer" method="post"> 
    <input class="big_search" name="email" type="text" placeholder="Enter email address" /> 
    <input class="big_submit" value="START FREE TRIAL" type="submit"> 
</form> 

路線:

Route::get('/mailer', '[email protected]');

控制器:

class MyController extends BaseController { 
    public function testEmail(){  
     Mail::send('emails.verification', array('key' => 'value'), function($message){ 
      $message->to('[email protected]', 'John Smith')->subject('Welcome!'); 
     }); 
    } 
} 

電子郵件查看,視圖/電子郵件/ verification.blade.php:

This is a test email

堆棧跟蹤/錯誤:

#13 Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5762 
#12 Illuminate\Routing\RouteCollection:methodNotAllowed in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5758 
#11 Illuminate\Routing\RouteCollection:getOtherMethodsRoute in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5736 
#10 Illuminate\Routing\RouteCollection:match in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5060 
#9 Illuminate\Routing\Router:findRoute in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5048 
#8 Illuminate\Routing\Router:dispatchToRoute in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5040 
#7 Illuminate\Routing\Router:dispatch in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:715 
#6 Illuminate\Foundation\Application:dispatch in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:696 
#5 Illuminate\Foundation\Application:handle in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:7812 
#4 Illuminate\Session\Middleware:handle in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:8419 
#3 Illuminate\Cookie\Queue:handle in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:8366 
#2 Illuminate\Cookie\Guard:handle in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:11029 
#1 Stack\StackedHttpKernel:handle in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:657 
#0 Illuminate\Foundation\Application:run in C:\xampp\htdocs\www\test\laravel-master\public\index.php:49 

回答

4

您張貼到你的控制器,但你的路線設置爲只接受GET請求:

Route::get('/mailer', '[email protected]') 

根本改變,要

Route::post('/mailer', '[email protected]') 

它應該工作

您的堆棧跟蹤的第一行:

#13 Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException in C:\xampp\htdocs\www\test\laravel-master\bootstrap\compiled.php:5762 

表明正在接收「MethodNotAllowedHttpException」,其指示使用的是不是由該路由

支持的HTTP方法發送到服務器的請求
+0

Grrrrr,非常漂亮!所有工作,非常感謝你! – AnchovyLegend 2015-01-31 18:06:56