Tôi đang cố gắng để thiết lập email cho dự án laravel đầu tiên của tôi, và đã vui mừng rằng có một laracast cho nó: https://laracasts.com/lessons/mailersKhông thể xác thực về lỗi máy chủ SMTP sử dụng gmail
Tôi đã làm theo các bước đơn giản, chọn gmail trong mail.php (x của gia tăng đối với giấu tên):
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '[email protected]', 'name' => 'Diane Kaplan'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => '[email protected]',
'password' => 'xxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
.env có (x của gia tăng đối với giấu tên) - các laracast không có chúng ta sử dụng MAIL_USERNAME và MAIL_PASSWORD, nhưng họ đang được cập nhật cho biện pháp tốt giả Tôi sẽ kéo từ đó sau:
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
[email protected]
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=null
Nhưng trong khoảnh khắc đầu tiên của sự thật cố gắng gửi thư (3:30 đánh dấu), tôi nhận được lỗi xác thực: Swift_TransportException trong dòng AuthHandler.php 181: Không xác thực được trên máy chủ SMTP với tên người dùng "dianexxxxx @ gmail.com "bằng cách sử dụng 3 trình xác thực có thể
Dựa trên đọc một chút ngăn xếp, tôi đã thử bật 'quyền truy cập vào các ứng dụng kém an toàn' trong cài đặt gmail của mình nhưng không thay đổi lỗi. (Và các bài viết khác về vấn đề này có các yếu tố khác đã tạo ra một vấn đề tồi tệ hơn tôi).
Không có gì nhảy ra khỏi tôi từ laravel.log (bên dưới) - bất kỳ ý tưởng nào?
[2015-11-26 12:25:55] local.ERROR: exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators' in /home/vagrant/Code/Family-laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:181
Stack trace:
#0 /home/vagrant/Code/Family-laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(307): Swift_Transport_Esmtp_AuthHandler->afterEhlo(Object(Swift_SmtpTransport))
#1 /home/vagrant/Code/Family-laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand()
#2 /home/vagrant/Code/Family-laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#3 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(395): Swift_Mailer->send(Object(Swift_Message), Array)
#4 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(181): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#5 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(220): Illuminate\Mail\Mailer->send('emails.welcome', Array, Object(Closure))
#6 /home/vagrant/Code/Family-laravel/app/Http/routes.php(59): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#7 /home/vagrant/Code/Family-laravel/app/Http/routes.php(59): Illuminate\Support\Facades\Mail::send('emails.welcome', Array, Object(Closure))
#8 [internal function]: App\Providers\RouteServiceProvider->{closure}()
#9 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(155): call_user_func_array(Object(Closure), Array)
#10 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(130): Illuminate\Routing\Route->runCallable(Object(Illuminate\Http\Request))
#11 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(704): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#12 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#13 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#16 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(706): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(671): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#18 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(631): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#19 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#21 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#25 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#27 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#28 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#31 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#34 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#37 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(42): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#43 /home/vagrant/Code/Family-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#44 /home/vagrant/Code/Family-laravel/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#45 {main}
cảm ơn, Milan! Yup tôi đã thử đề nghị đầu tiên nhưng hai người còn lại thì mới. Tôi vừa mới làm cả hai (và đã làm bộ nhớ cache của nghệ nhân: rõ ràng và cấu hình thủ công: bộ nhớ cache), nhưng thật đáng buồn là vẫn không có thay đổi về lỗi mà tôi nhận được: ( –
bạn có nhận được email thông báo rằng nỗ lực đăng nhập của bạn đã bị ngăn không cho gmail? –
thay đổi tệp .env của bạn thành tệp tôi đã đề cập ở trên. –