我想通过真实的 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"}>
My.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>
My.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 结构不支持端口和 usetls。
https://tracker.adobe.com/#/view/CF-4204467
我的建议是在应用程序范围内创建您自己的结构,然后传递给带有 argumentCollection 属性的 cfmail 标记。
关于coldfusion - this.smtpServersettings 正在将邮件发送到未送达的选项而不是 gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60462950/