Coldfusion CFMAIL and sendgrid

强颜欢笑 提交于 2019-12-12 07:27:24

问题


I have 2 clients on the same server that I host, that both send email through sendgrid.com (both have their own accounts).

I was looking at reports on sendgrid and noticed that categories from "client 1" were showing up in a report for "client 2".

I spent extensive time on the phone with sendgrid and they are telling me that a handful of emails 65 from a batch of 3000 for "client 1" show as being sent through "client 2"'s authenticated user.

In my scripting, I use coldfusion cfmail and I specify the SMTP address, username and password for that client into the tag.

A possible theory takes into account the "Maintain connection to mail server" check box under mail in the administrator.

"Select this check box to keep the connection to a mail server open for reuse after delivering a message (recommended)."

If both clients send email at the same time (very much possible) would the coldfusion mail spooling engine separate them out based on server/username and password or send them all through to the mail server that is currently open?

If I uncheck the maintain connection to mail server checkbox... what is the downside on resources? my clients send newsletters and transactional emails all day, maybe about 10k each client.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/13481713/coldfusion-cfmail-and-sendgrid

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