Laravel - 无法与主机 smtp.googlemail.com 建立连接:stream_socket_client():无法连接

Hải*_*inh 5 email laravel

我正在尝试使用 Laravel 从本地主机从 Gmail 发送电子邮件。我收到此错误:

Connection could not be established with host smtp.googlemail.com 
:stream_socket_client(): unable to connect to ssl://smtp.googlemail.com:465 
(A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed because 
connected host has failed to respond.)
Run Code Online (Sandbox Code Playgroud)

我的 .env 文件:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=myusername@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
Run Code Online (Sandbox Code Playgroud)

错误是什么?我需要更改服务器或防火墙中的某些设置吗?

hak*_*ste 6

在 .env 文件中尝试以下代码:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
mail_username=myusername@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
Run Code Online (Sandbox Code Playgroud)