Created
March 25, 2014 12:13
-
-
Save bennadel/9760650 to your computer and use it in GitHub Desktop.
EmailYak.cfc - A ColdFusion Wrapper For The Email Yak API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Create an instance of the Email Yak wrapper. ---> | |
<cfset emailYak = createObject( "component", "com.emailyak.EmailYak" ) | |
.init( application.apiKey ) | |
/> | |
<!--- | |
When sending attachments, they need to be encoded as Base64 | |
strings. Therefore, when we read in the binary, we simply have | |
to encode them. | |
---> | |
<cfset attachments = [ | |
{ | |
filename = "alisha_morrow.jpg", | |
content = toBase64( fileReadBinary( expandPath( "./attachments/alisha_morrow.jpg" ) ) ) | |
}, | |
{ | |
filename = "jen_rish.jpg", | |
content = toBase64( fileReadBinary( expandPath( "./attachments/jen_rish.jpg" ) ) ) | |
} | |
] /> | |
<!--- Send an email with attachments. ---> | |
<cfset response = emailYak.sendEmail( | |
fromAddress = "ben@emailyakcfc.simpleyak.com", | |
fromName = "Ben Nadel", | |
toAddress = "ben@bennadel.com", | |
subject = "This is a test from EmailYak.cfc", | |
htmlBody = "Email Yak, it really whips the llama's ass.", | |
textBody = "Email Yak, it really whips the llama's ass.", | |
attachments = attachments | |
) /> | |
<!--- Output the response. ---> | |
<cfdump | |
var="#response#" | |
label="Send Email Response" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment