Akbarsait's Blog

ColdFusion 9: New Application Level SMTP Sever Settings for CFMail

ColdFusion 9 shipped with lots of new features that include some new variables which are added to the Application.cfc file. One among them is the new application level SMTP server setting. 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>

The above code has the "this.smtpServersetting" property defined in the Application.cfc file.

<cfmail
      from="fromEmaiID"
      to="toEmaiID"
      subject="ColdFusion 9 New smtpServersettings Feature"
      type="HTML">


   <p>
      Dear ColdFusion,
   </p>
   
   <p>
      You make my life much easier with your every cool
      and new features and functionalities.
   </p>

</cfmail>

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.

And another great feature to mention is ColdFusion 9 Administrator will have a new interface which allows us to view the undelivered emails in the ColdFusion Administrator itself. ColdFusion Rocks!

CF9SMTPServerSettings

David R's Gravatar Nice feature Akbar!.. And to make CF to resend an undelivered mail, we just need to copy the contents from "Undelivr" directory to the "Spool" directory, and that will do!.
# Posted By David R | 10/12/09 4:42 AM
Ben Nadel's Gravatar This is an awesome feature! Seems like this will be great for setting of development / production separation of email concerns.
# Posted By Ben Nadel | 10/12/09 12:50 PM
Akbarsait's Gravatar @David
Glad you like this feature.


@Ben
This is really an awesome addition to ColdFusion 9 and will be helpful for developers to mention the Email servers for Dev / Staging / Production environment.
# Posted By Akbarsait | 10/13/09 9:01 AM
Naveen's Gravatar Cool Feature... Nice post Akbar... Please do keep the good work up...
# Posted By Naveen | 10/16/09 1:51 AM