cakephp - 我正在使用 CakePHP 3.7 开发一个网站。我在 localhost 上工作,想从 localhost 向 gmail 发送电子邮件,但出现错误
问题描述
我能够从 xampp (Mecury) localhost 向 localhost 发送电子邮件。但是当我尝试从 Gmail 向本地主机发送电子邮件时,我无法做到这一点。
我们的主要目的是从 Gmail 帐户向本地主机发送电子邮件。我该怎么做,任何帮助都将不胜感激。
这是我的app.php文件中的代码:
'EmailTransport' => [
'default' => [
//'className' => MailTransport::class,
'className' => 'Smtp',
/*
* The following keys are used in SMTP transports:
*/
'host' => 'smtp.gmail.com',
'port' => 587,
'timeout' => 30,
'username' => 'my@gmail.com',
'password' => 'secret',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => ['demotest@localhost.com' => 'demotest'],
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],
解决方案
推荐阅读
- node.js - 尝试从 Nodejs 连接到 SQL Server Express
- python - PySpark:如何根据其他行值的值更改行+列的值
- google-analytics - “历史更改”事件后触发“仅链接”事件
- homebrew - “客户端不支持服务器请求的身份验证协议;考虑升级 MySQL 客户端”即使在降级到 mysql@5.7 后
- c# - 当设备在线时,Xamarin.Forms iOS 抛出 NSURLErrorDomain“互联网连接离线”
- wordpress - WordPress - 将用户角色限制为只能编辑高级自定义字段专业选项页面的内容
- android - 基于回收器滚动更改 AppBarLayout 的背景颜色而不折叠
- nginx - 如何为 nginx 提供存储桶路径?
- laravel - Laravel Eloquent,“继承”覆盖来自父级的字段
- python-3.x - 如何在不连接到计算机上活动实例的情况下运行 Python 脚本