laravel - Laravel - 无法与主机 smtp.googlemail.com 建立连接:stream_socket_client():无法连接
问题描述
我正在尝试使用本地主机的 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.)
我的 .env 文件:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=myusername@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
错误是什么?我需要更改服务器或防火墙中的某些设置吗?
解决方案
在 .env 文件中尝试以下代码:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
mail_username=myusername@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
推荐阅读
- python - Python:将两列数据框转换为一个插入列表
- ruby-on-rails - 如何读取 JSON 错误消息 React-Rails
- python-3.x - Python - Keras API 服务器在经过训练的自定义模型上处理图像
- c - 如何在 POST 请求中发送图像文件后将其保存在 C Web 服务器中
- css - 如何在 Vuetify v-menu 组件中创建三角形指针?
- javascript - 如何使用 Jest/Supertest/Knex/Postgres 处理外键约束
- python-3.x - 在 Python3 中生成所有给定长度的二进制掩码的最佳方法 [最佳时间复杂度] 是什么?
- javascript - javascript if 或语句
- python - Python while循环,从数组中打印一项而不连续打印两次
- javascript - Sequelize 创建/导入动态生成的模型