web-dev-qa-db-ja.com

Laravel SwiftMailer:応答コード250が必要ですが、コード "530"が返され、メッセージ "530-5.5.1認証が必要です

laravel 5.2、and using Swift Mailer for password resetting。Gmailで2段階認証を使用しています。

グーグルヘルプが言うように:


アカウントで2段階認証プロセスを有効にしている場合は、通常のパスワードではなくアプリパスワードの入力が必要になることがあります。


mail.phpに次の設定があります。

return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'Host' => env('MAIL_Host', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 465),
    'from' => ['address' => '[email protected]', 'name' => 'Shafee'],
    'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
    'username' => env('[email protected]'),
    'password' => env('MY_Gmail_API_KEY'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => env('MAIL_PRETEND', false),

];

.envでは、次のようになっています。

MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=MY_Gmail_API_KEY
MAIL_ENCRYPTION=ssl

次のエラーが表示されます。

Swift_TransportException in AbstractSmtpTransport.php line 383:

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. 

Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 w10sm15831823wjk.18 - gsmtp
"
5
Gammer

このページ で、アカウントの「安全性の低いアプリ」をオンにしてみてください。 this google answer をお読みください。

2
Rifki

Sslの代わりにtlsを使用し、ポート587を使用します。

キーまたはパスワードを使用します。

またはphp artisan config:cacheを実行してください

または、このページでアカウントの「安全性の低いアプリ」をオンにしてみてください。

4
Laravel User

このファイルをフォローしてください......

"Username" => env('[email protected] ') "Usernameに変更します"=> '[email protected]';

パスワードと同じ...

戻る[

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
|            "ses", "sparkpost", "log"
|
*/

'driver' => env('MAIL_DRIVER', 'smtp'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the Host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'Host' => env('MAIL_Host', 'smtp.gmail.com'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the Host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', 587),

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => ['address' => '[email protected]', 'name' => 'shashikant parmar111'],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

**'username' => '[email protected]',**

/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/

**'password' => '********',**

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,

];

2

Laravelでは、私も同じ問題を抱えていましたが、それは... Mail関数で「use句」を使用していなかったためです。

「use句」を使用するとエラーが解決しました。

1
Rashmi Jain

次の手順を試すことができます

  1. アカウントの「安全性の低いアプリ」をオンにします こちら
  2. 587ファイルでメールの暗号化をtlsに、ポートを.envに設定してみてください
    MAIL_Host = smtp.gmail.com
    MAIL_PORT = 587
    [email protected]
    MAIL_PASSWORD =あなたのパスワード
    MAIL_ENCRYPTION = tls
  3. 次に、php artisan cache:clearを実行します。

これでうまくいきました。

1
Joynal Abedin