在Laravel中注册时无法向用户发送电子邮件

时间:2020-04-11 05:55:27

标签: php gmail email-integration laravel-7

我到处搜索,试图解锁帐户中的“ LESS SECURE APPS”,并试图解锁验证码。但是没有任何帮助。还有其他事情要做吗?

此错误:

Failed to authenticate on SMTP server with username "my@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
 535 5.7.8 

.env文件

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MY-GMAIL@gmail.com
MAIL_PASSWORD=MY-PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=THE-SENDER-EMAIL@outlook.pt
MAIL_FROM_NAME="${APP_NAME}"

控制器类代码

public function build()
    {
        return $this
            ->subject('Your account created with success!')
            ->replyTo('MY-REPLY-MAIL@outlook.pt')
            ->view('emails.user-registered')
            ->with(['user' => $this->user]); 
    }

1 个答案:

答案 0 :(得分:1)

我只是发布,也许有人会需要它。 我解决了打开帐户Less secure apps

中不安全的应用程序的问题

然后我将密码放在双引号中。

我希望它能帮助其他人。