-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SES.cfc
54 lines (45 loc) · 1.37 KB
/
SES.cfc
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
50
51
52
53
54
/**
*
* @file /f/dev/amazon/SES.cfc
* @author Manuel H. Mueller [ Onko ] [email protected]
* @description
*
*/
component output="false" displayname="SES" extends="Connector" {
public function init( required string awsAccessKeyId, required string awsAccessSecret, string endpoint='email-smtp.eu-west-1.amazonaws.com'){
this.endpoint = endpoint;
this.awsAccessKeyId = awsAccessKeyId;
this.awsAccessSecret = awsAccessSecret;
return this;
}
public boolean function sendMail(required string to, required string from, required string subject, string plain='', string html='')
{
var body = "Action=SendEmail";
var count = 1;
if (listLen(to,',' )){
loop list="#to#" index="listItem" {
body &= '&Destination.ToAddresses.member.' & count & '=' & trim(listItem);
count++;
}
}
else
body &= '&Destination.ToAddresses.member.1=' & trim(to);
if(len(html))
body &= '&Message.Body.Html.Data=' & trim(html);
else if(len(plain))
body &= '&Message.Body.Text.Data=' & trim(plain);
else
body &= '&Message.Body.Text.Data=';
body &= "&Message.Subject.Data=#trim(subject)#&Source=#trim(from)#";
var result = makeRequest (
endpoint=this.endpoint,
awsAccessKeyID=this.awsAccessKeyId,
awsAccessSecret=this.awsAccessSecret,
body=body,
requestMethod='no-header'
);
if(result.status == 200)
return true;
return false;
}
}