質問: laravel 5.1でgmailを使ってメールを送信するにはどうすればいいですか? localhostからのメール送信を何度も試してみますが、まだできません。やり方がわからなくなった。解決策を見つけるために検索を試みますが、見つけることができません。 config/mail.phpを編集しました。<?php return [ /* |-------------------------------------------------------------------------- | 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", "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' => 'myemail@gmail.com', 'name' => 'do not reply'], /* |-------------------------------------------------------------------------- | 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' => env('mail_username'), /* |-------------------------------------------------------------------------- | 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' => env('mail_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', /* |-------------------------------------------------------------------------- | mail "pretend" |-------------------------------------------------------------------------- | | when this option is enabled, e-mail will not actually be sent over the | web and will instead be written to your application's logs files so | you may inspect the message. this is great for local development. | */ 'pretend' => false, ]; ` そして私は.envファイルを既にこのように編集しました:mail_driver=smtp mail_host=smtp.gmail.com mail_port=587 mail_username=myemail@gmail.com mail_password=password mail_encryption=null それでもまだこのようなエラーが発生しました:
回答: あなたが電子メールのパスワードを使用しているなら、あなたは後で無効にすることができるパスワードを設定する前にあなたが2ステップ認証を有効にする必要があるappパスワードを設定するためにapp password.forとそれを取り替えるべきです。また、設定セクションで安全性の低いアプリを許可していることを確認してください。追加情報については、次の方法で確認できます ここ