com.sebtools Build 12 Documentation: Mailer.cfc

Mailer.cfc

Mailer.cfc is a component to handle sending email from ColdFusion. It is essentially another layer of abstraction over cfmail.

This extra layer of abstraction does add some advantages. It allows all email settings to be centralized. This would include the username/password settings (or lack thereof).

Additionally, it provides the ability to switch to a simulated mailer that logs (but doesn't send) email.

This is especially useful when dealing with CFCs, as it allows you to pass in the mailer component instead of several settings for email. Combined with the simulated mailer (covered later), this is also ideal for development and testing.

To use Mailer.cfc, follow these steps:

  1. Download Mailer.cfc
  2. Place it where you want to store it (code example assumes root of site or CustomTags directory).
  3. Initialize Mailer.cfc
Application.Mailer = CreateObject("component","Mailer").init("mail.example.com","from@example.com")

Note that "mail.example.com" (the MailServer) and from@example.com (the default from address) could also be a variables.

CFC Docs