Avg. Rating 4.0

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.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes