Configuration

Application Configuration

You can configure the module by creating a cbmailservices key under the moduleSettings structure in the config/Coldbox.cfc file. Here you will configure all the different mailers, default protocol, default sending settings and so much more.
1
moduleSettings = {
2
cbmailServices = {
3
// The default token Marker Symbol
4
tokenMarker : "@",
5
// Default protocol to use, it must be defined in the mailers configuration
6
defaultProtocol : "default",
7
// Here you can register one or many mailers by name
8
mailers : {
9
"default" : { class : "CFMail" },
10
"files" : { class:"File", properties : { filePath : "/logs" } },
11
"postmark" : { class:"PostMark", properties : { apiKey : "234" } }
12
},
13
// The defaults for all mail config payloads and protocols
14
defaults : {
15
17
},
18
//Whether the scheduled task is running or not
19
runQueueTask : true
20
}
21
}
Copied!
By default, the mail services are configured to send mail via the cfmail tag using a mailer called default.

TokenMarker

The tokenMarker is used when doing mail merges with variables. The service will look in the body of the email and do replacements according to the following pattern:
1
@{key}@
Copied!

DefaultProtocol

The name of the mailer key that will be used by default to send mail. The default is called default.

Mailers

A structure of mailer protocol registrations by key name. Each mailer is registered with the following pattern:
1
mailerKey : {
2
class : "Alias|wireBoxID|CFCPath",
3
properties : {}
4
}
Copied!

Defaults

A structure of default variables that will be seeded into the Mail payload. These are then used by the protocols as defaults. For example, the CFMail protocol will use all these as defaults to the cfmail tag.

RunQueueTask

By default, a task runs every minute to facilitate the sending of email asynchronously (non-blocking). Setting runQueueTask to false will override the default and the task will not run.

Mail Protocols

The mail services can send mail via different protocols. The available protocol aliases you can register are:
  • CFMail
  • Null
  • InMemory
  • File
  • Postmark
Please note that some of the protocol have property requirements.
1
defaultProtocol : "default",
2
mailers : {
3
// Default CFMail
4
"default" : {
5
class : "CFMail"
6
},
7
​
8
// FileProtocol
9
"files" = {
10
class = "File",
11
// Required Properties
12
properties = {
13
filePath = "logs",
14
autoExpand = true
15
}
16
},
17
​
18
// NullProtocol
19
"null" = {
20
class = "Null",
21
properties = {}
22
},
23
​
24
// InMemoryProtocol
25
"memory" = {
26
class = "InMemory",
27
properties = {}
28
},
29
​
30
// PostMark
31
"postmark" = {
32
class = "Postmark",
33
// Required properties
34
properties = {
35
APIKey = "123"
36
}
37
};
38
}
Copied!

Mailer WireBox ID

You can also register ANY WireBox ID or class path as the mailer as well. This will allow you to register mailers that come from your application or any other module.
1
moduleSettings = {
2
cbMailservices : {
3
defaultProtocol : "default",
4
mailers : {
5
"default" : { class : "CFmail" },
6
// Custom amazon mailer from the amazonsns module
7
"amazon" : { class : "[email protected]" }
8
}
9
}
10
}
Copied!
Export as PDF
Copy link
Edit on GitHub