How to use the new email plugin

Hi all,

I am looking into the new email plugin, which sounds very usefull.

I am very interested in how to send an email with tokens with the
plugin but I can not find any documentation yet.

Anyone used this plugin, and wants to share how they have done it?

Kind regards,

Erik-Jan Jaquet


It is very simple, you can read the API to understand it. Here is a simple breakdown until the docs are complete:

  1. get a new mail object: getPlugin(“MailService”).newMail();
    Populate it with your mail information and then you can also set a structure of name-value pairs as tokens:

tokens = {name=“Luis Majano”,time=dateformat(now(),“full”)};

Once the tokens are set,the mail service will try to match them in the body of a message and replace them. So I can do this:

mail.setBody(“Hello @name@, how are you today? Today is the @time@”);

As you can see, tokens are in the format of @token-name@, then the service will replace them for you. Then just send them using the send() method.

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:

Are you using 3.0? If you are, you could inject the plugin where needed and do something like below. I’m referencing it as “instance.mailSevice” because I’m injecting it but the same can be done using getPlugin() where applicable.

  1. Get a new mail object
  1. Configure the object’s properties. You can use the config function or setters. CFDUMP to easily see all the setters or look at coldbox/system/beans/Mail.cfc

<cfset emailObject.config(from = whatever1
,username = whatever2

  1. Send the email

<cfset instance.mailservice.send(emailObject)>

PS. “coldbox/system/beans/Mail.cfc” may have type=“int” references that don’t work in CF8 or CF9. Change those to type=“numeric” to get it working for now.

  • Gabriel

Hi Luis, Gabriel,

Thanks for your input! It is working great now! The new Coldbox 3.0 looks promising!

Kind regards,


2009/11/9 Luis Majano <>