エラー内容
Swift_TransportException with message 'Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
認証が必須とエラーがでました。
gmail側の設定として"gmailの設定/imap"を無効から有効にしました。
実装は以下の通り
passはアプリ認証ようのものを使ってます(https://security.google.com/settings/security/apppasswords)
php
1vi .env # 以下を追加 2MAIL_DRIVER=smtp 3MAIL_HOST=smtp.gmail.com 4MAIL_PORT=587 5MAIL_ENCRYPTION=tls 6MAIL_FROM_ADDRESS=xxxxxxxx@gmail.com 7MAIL_FROM_NAME=xxxxxxxx 8MAIL_USERNAME=xxxxxxxx@gmail.com 9MAIL_PASSWORD=xxxxxxxxxxxxxxxx 10MAIL_PRETEND=false 11 12 13vi config/mail.php # 以下を修正 14'from' => [ 15 'address' => env('MAIL_FROM_ADDRESS', null), 16 'name' => env('MAIL_FROM_NAME', null) 17], 18 19php artisan tinker 20Mail::raw('Test Mail', function($message) { $message->to('xxxxxxxxxxxxxxxx@gmail.com')->subject('test'); }); 21Swift_TransportException with message 'Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
.envを読み込んでないのかと思い、config/mail.phpへ設定を直書きしましたが同じエラーでした。
php
1vi config/mail.php 2return [ 3 'driver' =>'smtp', 4 'host' => 'smtp.gmail.com', 5 'port' => 587, 6 'from' => [ 7 'address' => 'xxxxxxxx@gmail.com', 8 'name' => 'xxxxxxxx' 9 ], 10 'encryption' => 'tls', 11 'username' => 'xxxxxxxx@gmail.com', 12 'password' => 'xxxxxxxxxxxxxxxx', 13 'sendmail' => '/usr/sbin/sendmail -bs', 14]; 15
ちなみにPear::Mailを使ったgmailへの送信はうまくいってるので、gmail側の設定は問題ないようです。
その時の設定は以下のような感じでした。
php
1$params = [ 2 'host' => 'smtp.gmail.com', 3 'port' => 587, 4 'auth' => true, 5 'username' => 'xxxxxxxxxxxxxxxx@gmail.com', 6 'password' => 'xxxxxxxxxxxxxxxxxxxxxxxx' 7 ];
laravel5でメール送信されている方いらっしゃいませんでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。