Coldfusion CFMAIL and sendgrid

寵の児 提交于 2019-12-01 17:55:11

I don't know what version of ColdFusion you are running but in ColdFusion 9 a new feature was added that allows you to specify the SMTP server settings in your Application.cfc file. Assuming that you have separate Application.cfc files for your 2 sites then perhaps this will work for you.

Here is a reference to the new feature in ColdFusion 9

Here is the text from that referenced page.

Problem
How can I use the different SMTP Server Settings for Applications hosted in ColdFusion server for sending Email.

Solution
By using the new ColdFusion 9 “smtpServersettings" feature in Application.cfc file, we can specify different SMTP server settings for Applications.

Detailed explanation
ColdFusion 9 added a new attribute called "smtpServersettings" to the Application.cfc file. We can specify the SMTP server setting details to "smtpServersettings" attribute of THIS scope in Application.cfc which takes three values and they are server, username and password as a structure.

<cfcomponent displayname="CF9ApplicationVariables" output="false">

   <cfset this.name   = "CF9ApplicationVariables" />
   <cfset this.smtpserversettings   = {
                          server="mailServerAddress",
                          username="userEamilID",
                          password="userPassword"
                          } />
</cfcomponent>

Now the CFMail tag will use the server details for sending mails as mentioned above in "smtpServersetting" in Application.cfc and it won't use the server values specified in the ColdFusion 9 Administrator. If "smtpServersetting" attribute is not used then CFMail will behave as normally.

I ended up modifying the DNS settings in my servers, adding a cname that pointed to the smtp address, smtp.sendgrid.net. I then updated my code to use the new server names, and this seems to be separating the connections.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!