首页 > 解决方案 > 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 是否需要启用任何其他设置?请帮助我。如果我理解错了,请纠正我。谢谢 !。

标签: coldfusioncfmailcoldfusion-2018

解决方案


smtpServerSettings 结构不支持 port 和 usetls。

https://tracker.adobe.com/#/view/CF-4204467

我的建议是在应用程序范围内创建自己的结构,然后使用 argumentCollection 属性传递给 cfmail 标记。


推荐阅读