Laravel通过Gmail发送邮件

时间:2016-05-05 11:28:06

标签: laravel email gmail send

我似乎无法让它发挥作用:

ENV

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=my_acc@gmail.com
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls

在控制器中:

Mail::send('mail.template', ['post' => $post, 'user' => $user], function($message) {
            $message->to('my_acc@gmail.com', 'X Y')->subject('Comment');
        });

我得到错误:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

我尝试将其添加到StreamBuffer.php

$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;

然后我收到了这个错误:

Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.

即使我没有得到这个错误,我想要一个解决方案,而不是快速修复...

1 个答案:

答案 0 :(得分:0)

使用您的MAIL_ENCRYPTION=ssl,应该可以正常使用。