`I am setting up mailing functionality in my website using mailgun. I can send mail using the mailgun API, both text and HTML content. However, I need to sent mail with calendar attachment, but couldn't find any better way to do that in ColdFusion. Could any one please help me out?
<cfhttp result="result" method="POST" charset="utf-8"
url="https://api.mailgun.net/v3/sandbox0000000000000000000.mailgun.org/messages" >
<cfhttpparam type="header" name="Authorization"
value="Basic #ToBase64("api:***********************************79")#" />
<cfhttpparam type="formfield" name="from"
value="[email protected]" >
<cfhttpparam type="formfield" name="to" value="[email protected]" />
<cfhttpparam type="formfield" name="subject" value="mail content" />
<cfhttpparam type="formfield" name="text" value="mail content from test account" />
<cfhttpparam type="formfield" name="attachment" value="my path" />
</cfhttp>
For the invite.ics
calendar file, I first wrote this file into a folder and so I can provide the path to cfhttpparam
for the name attachment
. After sending the mail I just removed that from my folder. It is simple as that for any type of file.
<cfhttp result="result" url="https://api.mailgun.net/v3/sandbox0000000000000000000.mailgun.org/messages" method="POST">
<cfhttpparam type="header" name="Authorization" value="Basic #ToBase64("api:***********************************79")#" />
<cfhttpparam type="FORMFIELD" name="from" value="[email protected]">
<cfhttpparam type="FORMFIELD" name="to" value="[email protected]">
<cfhttpparam type="FORMFIELD" name="subject" value="attachment test">
<cfhttpparam type="FORMFIELD" name="text" value="Hello">
<cfhttpparam type="formfield" name="html" value="<html>Testing with text/calendar******* type</html>" />
<cfhttpparam type="file" name="attachment" file="#yourattachementfilepath here#" >
</cfhttp>