laravel 5:发送电子邮件不起作用

时间:2015-10-08 09:25:07

标签: php html-email laravel-5.1

我是laravel的新手,我在尝试发送这样的电子邮件时遇到困难:

    Mail::send('emails.pwreset', $mydata, function ($message) use ($mydata) {
        $message->from('foo@bar.de', 'Password reset');

如何启用/配置邮件功能?

这是我的laravel错误消息:

Swift_TransportException in StreamBuffer.php line 294: Process could not be started [Das System kann den angegebenen Pfad nicht finden.
]
in StreamBuffer.php line 294
at Swift_Transport_StreamBuffer->_establishProcessConnection() in StreamBuffer.php line 58
at Swift_Transport_StreamBuffer->initialize(array('timeout' => '30', 'blocking' => '1', 'command' => '/usr/sbin/sendmail -bs', 'type' => '16')) in AbstractSmtpTransport.php line 113
at Swift_Transport_AbstractSmtpTransport->start() in SendmailTransport.php line 51
at Swift_Transport_SendmailTransport->start() in Mailer.php line 79
at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 398
at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 188
at Mailer->send('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo@bar.de'), object(Closure)) in Facade.php line 216
at Facade::__callStatic('send', array('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo@bar.de'), object(Closure))) in ResetpwController.php line 58
at Mail::send('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo@bar.de'), object(Closure)) in ResetpwController.php line 58
at ResetpwController->resetted(object(Request))
at call_user_func_array(array(object(ResetpwController), 'resetted'), array(object(Request))) in Controller.php line 256
at Controller->callAction('resetted', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ResetpwController), object(Route), 'resetted') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(ResetpwController), object(Route), object(Request), 'resetted') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Resetpw\ResetpwController', 'resetted') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54

1 个答案:

答案 0 :(得分:1)

看起来/usr/sbin/sendmail不存在。 sendmail是否已安装并正确配置?

同时检查应用程序内的Swift Mailer设置。