coldfusion - this.smtpServersettings 将邮件发送到未投递的选项而不是 gmail
问题描述
我想向最终用户发送一封真实 gmail ID 的电子邮件。所以我使用smtp.gmail.com作为邮件服务器,使用我自己的电子邮件用户名和密码。但是,如果我在 application.cfc 中使用this.smtpServersettings,它不会发送电子邮件。所有邮件都转到未投递的选项。我的示例代码 App.cfc :
<cfset this.name='mailfn8'>
<cfset this.smtpServersettings={server:"smtp.gmail.com",username:"mygmail@gmail.com",password:"mypassword"}>
我的.cfm:
<cfmail from='sender@gmail.com' to='receiver@gmail.com' subject='test' type='html' port="587" usetls="true">
I'm seding a email by using this.smtpServersettings options.
</cfmail>
但是凭据在以下情况下效果很好,
-- If I set my details in application scope and use that values in cfmail tag
-- Directly set it in coldfusion mail server setting
例如, App.cfc :
<cfset this.name='mailfn8'>
<cffunction name='onApplicationStart'>
<cfset application.server='smtp.gmail.com'>
<cfset application.username='mygmail@gmail.com'>
<cfset application.password='mypassword'>
</cffunction>
我的.cfm:
<cfmail from='sender@gmail.com' to='receiver@gmail.com' server= '#application.server#' username='#application.userName#' password='#application.password#' subject='test' type='html' port="587" usetls="true">
I'm seding a email by using application scope.
</cfmail>
以上工作正常。那么为什么 this.smtpServersettings 将电子邮件发送到未送达选项而不是 gmail。? .如果我使用 this.smtpServerSetting 是否需要启用任何其他设置?请帮助我。如果我理解错了,请纠正我。谢谢 !。
解决方案
smtpServerSettings 结构不支持 port 和 usetls。
https://tracker.adobe.com/#/view/CF-4204467
我的建议是在应用程序范围内创建自己的结构,然后使用 argumentCollection 属性传递给 cfmail 标记。
推荐阅读
- foreach - For-Each 模块中的 Terraform 参考项
- c# - 使用蓝牙 HFP 配置文件从耳机获取电池电量
- html - PieChar里面for循环标记html django
- python - 如何从对象中的对象加载参数?
- c++ - 免受 MySQL 连接器/C++ 中的 sql 注入查询/语句的影响
- firebase - 颤振实时数据库未显示
- reactjs - fetchall() 加载指示器(简单易用)在带有 axios 的 react-redux Web 应用程序中
- c# - 将 ValidationMetadataProviderContext 与 Validator 对象一起使用
- wordpress - 在本地创建一个 Git 存储库以供外部源连接
- java - 如何从excel表中读取多个选项卡并转换为java spark中的每个Dataframe