Laravel(Mandrill / Ajax)发送电子邮件发送开发而非生产

时间:2015-05-16 23:17:58

标签: php jquery ajax laravel

我整晚都在尝试不同的事情,而对于我的生活,我无法让我的网站发送电子邮件。我刚刚将我的第一个Laravel项目部署到一个实时服务器(digitalocean),但是当我在我的vagrant dev机器上发送电子邮件时没有问题,直到我部署问题才开始。

我知道500错误通常是由于CSRF令牌并将其传递到您的标题中,但我这样做仍然会出错。我会发布我认为相关的代码,如果有人能看到我做错了什么,我将永远为你负债。

MAIL :( Asterix for privacy)

return [
    'driver' => 'smtp',
    'host' => 'smtp.mandrillapp.com',
    'port' => 587,
    'from' => array('address' => '********@gmail.com', 'name' => 'Admin'),
    'encryption' => 'tls',
    'username' => '********@gmail.com',
    'password' => '****************',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,
];

用于电子邮件发送的HomeController @store方法(适用于开发)

public function store(ContactFormRequest $request)
{
    Mail::send('emails.email', array(
            'name' => $request->get('name'),
            'email' => $request->get('email'),
            'user_message' => $request->get('user_message')
        ), function($message)
    {
        $message->from('*********@gmail.com');
        $message->to('********@gmail.com', 'Admin')->subject('Client Inquiry');
    });

    return Response::json(['response' => 200]);
}

AJAX(jQuery)

$('#submit-contact-form').click(function(e) {
    e.preventDefault();
    $('#submit-contact-form').val('Sending...');
    var $form = $(this).parent('form');
    var $action = $form.attr('action');
    var $data = $form.serialize();

$.ajax({
    url: $action,
    method: 'POST',
    headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') },
    data: $data,
    success: function(data) {
        if (data.response == 200) {
            $('#submit-contact-form').val('Thank You For Contacting Us!');
        }
    }
});

});

Routes.php :(联系表单在我的主页上并发布到自己,在dev上工作)

Route::resource('/', 'HomeController', ['only' => ['index','store']]);

最后表单:(如果发布到root,则发现,对于url,您必须传递空字符串,其中包含空格

{!! Form::open(array('url' => ' ', 'id' => 'contact-form')) !!}
    blah blah blah
{!! Form::close() !!}

我是Laravel的新手,所以我还在学习,但是这个让我陷入困境,特别是因为它适用于开发而不是制作。

这是我的错误日志:

[2015-05-14 06:29:01] production.ERROR: exception 'ErrorException' with message 'Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in /var/www/html/kraken/vendor/compiled.php on line 11268 and defined' in /var/www/html/kraken/vendor/compiled.php:11262
Stack trace:
#0 /var/www/html/kraken/vendor/compiled.php(11262): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Missing argumen...', '/var/www/html/k...', 11262, Array)
#1 /var/www/html/kraken/vendor/compiled.php(11268): Illuminate\Support\Manager->createDriver()
#2 /var/www/html/kraken/vendor/compiled.php(11258): Illuminate\Support\Manager->createDriver(NULL)
#3 /var/www/html/kraken/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(92): Illuminate\Support\Manager->driver()
#4 /var/www/html/kraken/vendor/compiled.php(827): Illuminate\Mail\MailServiceProvider->Illuminate\Mail\{closure}(Object(Illuminate\Foundation\Application))
#5 /var/www/html/kraken/vendor/compiled.php(1027): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#6 /var/www/html/kraken/vendor/compiled.php(980): Illuminate\Container\Container->build(Object(Closure), Array)
#7 /var/www/html/kraken/vendor/compiled.php(1493): Illuminate\Container\Container->make('swift.mailer', Array)
#8 /var/www/html/kraken/vendor/compiled.php(1213): Illuminate\Foundation\Application->make('swift.mailer')
#9 /var/www/html/kraken/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(30): Illuminate\Container\Container->offsetGet('swift.mailer')
#10 /var/www/html/kraken/vendor/compiled.php(1027): Illuminate\Mail\MailServiceProvider->Illuminate\Mail\{closure}(Object(Illuminate\Foundation\Application), Array)
#11 /var/www/html/kraken/vendor/compiled.php(980): Illuminate\Container\Container->build(Object(Closure), Array)
#12 /var/www/html/kraken/vendor/compiled.php(1493): Illuminate\Container\Container->make('mailer', Array)
#13 /var/www/html/kraken/vendor/compiled.php(1213): Illuminate\Foundation\Application->make('mailer')
#14 /var/www/html/kraken/vendor/compiled.php(5276): Illuminate\Container\Container->offsetGet('mailer')
#15 /var/www/html/kraken/vendor/compiled.php(5262): Illuminate\Support\Facades\Facade::resolveFacadeInstance('mailer')
#16 /var/www/html/kraken/vendor/compiled.php(5296): Illuminate\Support\Facades\Facade::getFacadeRoot()
#17 /var/www/html/kraken/app/Http/Controllers/HomeController.php(28): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#18 /var/www/html/kraken/app/Http/Controllers/HomeController.php(28): Illuminate\Support\Facades\Mail::send('emails.email', Array, Object(Closure))
#19 [internal function]: App\Http\Controllers\HomeController->store(Object(App\Http\Requests\ContactFormRequest))
#20 /var/www/html/kraken/vendor/compiled.php(8287): call_user_func_array(Array, Array)
#21 /var/www/html/kraken/vendor/compiled.php(8354): Illuminate\Routing\Controller->callAction('store', Array)
#22 /var/www/html/kraken/vendor/compiled.php(8333): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\HomeController), Object(Illuminate\Routing\Route), 'store')
#23 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#25 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 /var/www/html/kraken/vendor/compiled.php(8334): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#28 /var/www/html/kraken/vendor/compiled.php(8320): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\HomeController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'store')
#29 /var/www/html/kraken/vendor/compiled.php(7317): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'store')
#30 /var/www/html/kraken/vendor/compiled.php(7288): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#31 /var/www/html/kraken/vendor/compiled.php(6954): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#32 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#34 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#36 /var/www/html/kraken/vendor/compiled.php(6955): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#37 /var/www/html/kraken/vendor/compiled.php(6944): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#38 /var/www/html/kraken/vendor/compiled.php(6929): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#39 /var/www/html/kraken/vendor/compiled.php(1935): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#41 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 /var/www/html/kraken/vendor/compiled.php(2438): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/html/kraken/app/Http/Middleware/VerifyCsrfToken.php(17): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/www/html/kraken/vendor/compiled.php(8944): App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#45 /var/www/html/kraken/vendor/compiled.php(12083): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /var/www/html/kraken/vendor/compiled.php(10785): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /var/www/html/kraken/vendor/compiled.php(11789): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#51 /var/www/html/kraken/vendor/compiled.php(11738): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#52 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/www/html/kraken/vendor/compiled.php(2478): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#55 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#56 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#57 /var/www/html/kraken/vendor/compiled.php(1891): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#58 /var/www/html/kraken/vendor/compiled.php(1880): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#59 /var/www/html/kraken/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#60 {main}  

我已经去了Laracast并发布但没有得到任何回复,如果有人可以帮助我,我会非常感激,谢谢你们。

0 个答案:

没有答案