-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.cfm
53 lines (39 loc) · 1.34 KB
/
example.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<cfscript>
//update with your actual api keys
apiKeyLive = "live-key-goes-here";
apiKeyTest = "test-key-goes-here";
liveMode = false;
//instantiate the api
api = CreateObject("component", "sendWithUsCfc.SendWithUsApi")
.init(apiKeyLive=apiKeyLive, apiKeyTest=apiKeyTest, liveMode=liveMode);
//construct the send request
sendRequest = api.newSendRequest()
.setEmailId("email-template-id-goes here")
.setRecipient({"address":"joe@somedomain.com"})
.setSender({"address": "support@the-sending-domain.com", "name": "Support"})
.setEmailData({"first_name": "Fred"})
.setCcRecipients([{ "name":"Sales Team","address":"sales@the-sending-domain.com"}, {"name": "Support", "address": "support@the-sending-domain.com"}]);
//call the api to send the email
apiResponse = api.send(sendRequest);
</cfscript>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>SendWithUsCfc Example</title>
</head>
<body>
<!--- handle the response from the api --->
<cfif apiResponse.statusCode EQ "200" >
<h3>Success!</h3>
<cfset sendReceipt = deserializeJSON(apiResponse.result) />
<cfdump var=#sendReceipt# label="sendReceipt" expand="false" />
<cfelse>
<h3>Error</h3>
<cfoutput>
#apiResponse.statusCode#<br />
#apiResponse.status#<br />
#apiResponse.message#</cfoutput>
</cfif>
</body>
</html>