2017-04-12 97 views
0

當我嘗試使用mailraun包發送郵件給laravel(bogardo/mailgun)時,會顯示此錯誤。試圖獲得非對象laravel bogardo/mailgun/src/http/response的屬性

路線:

Route::post('mail-list/send/{type}/{id}', ['uses' => 'MailingList\[email protected]', 'as' => 'mail-list.send']); 

控制器MailingListController

use Bogardo\Mailgun\Mail\Message; 
use Mailgun; 

控制器的方法:

public function sendSiteNews($type, $id) { 
    $data = []; 
    Mailgun::send('email.batch-news', $data, function (Message $message) { 
     $message->to('[email protected]', 'John Smith')->subject('Welcome!'); 
    }); 
]; 

起初我試過成批發送。結果是一樣的。之後,我嘗試發送類似上面的簡單消息。

查看email.batch-news僅包含帶有h1標籤的文本。

錯誤消息:

ErrorException在Response.php線35: 試圖獲得非對象

in Response.php line 35 
at HandleExceptions->handleError(8, 'Trying to get property of non-object', 'D:\\wamp\\www\\asiacrochet\\vendor\\bogardo\\mailgun\\src\\Http\\Response.php', 35, array('response' => object(stdClass))) in Response.php line 35 
at Response->__construct(object(stdClass)) in Mailer.php line 68 
at Mailer->send('email.batch-news', array(), object(Closure)) in Service.php line 59 
at Service->send('email.batch-news', array(), object(Closure)) in Facade.php line 221 
at Facade::__callStatic('send', array('email.batch-news', array(), object(Closure))) in MailingListController.php line 67 
at MailingListController->sendSiteNews('Lesson', '10') 
at call_user_func_array(array(object(MailingListController), 'sendSiteNews'), array('Lesson', '10')) in Controller.php line 55 
at Controller->callAction('sendSiteNews', array('Lesson', '10')) in ControllerDispatcher.php line 44 
at ControllerDispatcher->dispatch(object(Route), object(MailingListController), 'sendSiteNews') in Route.php line 203 
at Route->runController() in Route.php line 160 
at Route->run() in Router.php line 559 
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in HasRole.php line 24 
at HasRole->handle(object(Request), object(Closure), 'administrator') in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41 
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 43 
at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65 
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59 
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102 
at Pipeline->then(object(Closure)) in Router.php line 561 
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520 
at Router->dispatchToRoute(object(Request)) in Router.php line 498 
at Router->dispatch(object(Request)) in Kernel.php line 174 
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30 
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30 
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64 
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 47 
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102 
at Pipeline->then(object(Closure)) in Kernel.php line 149 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 
at Kernel->handle(object(Request)) in index.php line 53 

的屬性即包的方法,包括:

public function __construct(stdClass $response) 
    {dd($response->http_response_body); 
     $this->status = $response->http_response_code; 
     $this->message = $response->http_response_body->message; 
     $this->id = property_exists($response->http_response_body, 'id') ? $response->http_response_body->id : ''; 
     $this->data = null; 
    } 

dd($response->http_response_body); 

僅給出那個字符串值「Mailgun Magnificent API」。

這就是問題所在。

回答

0

檢查您的發送域名「email.batch-news」。如果這是不正確的mailgun,確定您正在調用的API方法。

+0

是的,這是我在mailgun信息中的錯。我花了好幾個小時才發現這個問題。 – GingerN

相關問題