Building Protocols
If you want to build your own protocol you will have to do the following
  1. 1.
    Create a CFC that inherits from cbmailservices.models.AbstractProtocol
  2. 2.
    Create the init() and send() methods
  3. 3.
    Give your protocol a name in the init() via the variables.name variable.
  4. 4.
    Register it in the mailers section of the configuration​
Here are the method signatures of the two methods to implement:
1
/**
2
* Constructor
3
*
4
* @properties The protocol properties to instantiate
5
*/
6
function init( struct properties = {} ){
7
variables.properties = arguments.properties;
8
variables.name = "MyProtocol";
9
return this;
10
}
11
​
12
/**
13
* Implemented by concrete protocols to send a message.
14
*
15
* The return is a struct with a minimum of the following two keys
16
* - `error` - A boolean flag if the message was sent or not
17
* - `messages` - An array of messages the protocol stored if any when sending the payload
18
*
19
* @payload The paylod object to send the message with
20
* @payload.doc_generic cbmailservices.models.Mail
21
*
22
* @return struct of { "error" : boolean, "messages" : [] }
23
*/
24
struct function send( required cbmailservices.models.Mail payload ){
25
​
26
}
Copied!
That's it!
Export as PDF
Copy link
Edit on GitHub