I am trying to use Mandrill with ColdFusion 6.1. ColdFusion is not one of Mandrell's supported languages. I am pretty sure I need to use cfhttp and Post. Are there any resources or example to help me along.
-
1Mandrill offers an smtp interface. You could use that if you simply want to send emails – Sean Coyne Aug 14 '14 at 23:02
2 Answers
I'm surprised that no one has released a CFC yet (and had previously tweeted about it), but the API is pretty simple. For example, you can communicate to Mandrill directly using javascript.
https://bitbucket.org/mailchimp/mandrill-api-js/
Mandril uses a restful API. Here's a link to the full documentation:
https://mandrillapp.com/api/docs/
In order to send a message, you need to POST a JSON packet using your own API key. (In the demo link, you can modify the JSON and click the "try it" button to send a test message.)
https://mandrillapp.com/api/docs/messages.JSON.html#method-send
You may need to manually generate your own JSON as ColdFusion tends to convert numbers and boolean values into strings.

- 4,360
- 1
- 22
- 21
-
Thanks for the "try me" info. I tried my JSON and it works fine. but when I run it through the CFHTTP tag The JSON appears to be corrupted. The code is as follows; `
-
Did you try using isJSON() AND DeserializeJSON() to determine if the JSON is valid or not? (Whoops... ColdFusion 8 only apparently.) You could test the JSON at http://jsonlint.com/ to determine if it's valid. (Remember to use double quotes.) – James Moberg Aug 20 '14 at 02:27
-
What did you find? Please post a link to it here so that other developers can benefit from what you found. Thx. – James Moberg Aug 22 '14 at 16:37
-
What I actually found was already in the code base I was working on. It is a much better JSON encoder but it is no longer downloadable as the author's web site is down. – Movak Aug 26 '14 at 17:09
You can simply use a cfmail
tag and set the smtp username and password to the values provided by Mandrill. They have a full set of documentation on using SMTP with Mandrill.
Here's some sample code:
<cfmail
from="you@you.com"
subject="Your subject line"
to="him@him.com"
type="HTML"
server="smtp.mandrillapp.com"
port="587"
username="yourusername"
password="yourkey"
>
<cfmailparam name="X-MC-Tags" value="Some tag to track in Mandrill" />
<cfmailparam name="X-MC-Track" value="opens,clicks" />
<cfmailparam name="X-MC-Autotext" value="false" />
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
A whole lot of body content goes here.
</body>
</html>
</cfmail>

- 9,598
- 2
- 28
- 53
-
I have it working with SMTP but I would prefer it to be able to use the JSON api. One difference is that the API only needs a key while the SMPT need the username and key. – Movak Aug 18 '14 at 17:01
-
I just found a stopper. I would like to use templates to send out standard documents like receipts. There is a limitation in the SMTP protocol that a header can not be more than 1000 characters long. The line item detail of a receipt can be much longer than that. – Movak Aug 18 '14 at 18:39
-
You're correct that a header can't be longer than 1000 characters, but your line item details should be in the body of the email, not in the headers. I routinely send large complex emails via the SMTP service at Mandrill without any problems. Updated my answer with an example. Just build your templates locally in your CF instead of relying on Mandrill and you're good to go. – Dan Short Aug 19 '14 at 12:15
-
If we build the template locally we may as well build the entire email locally. We have several customers who want different email layouts. We want to be able to use the Mandrill template editor to handle those layout. I am trying to avoid code changes every time a customer wants to move a field on an email. If wee send the same information to different templates and they are formatted differently for our different clients. I have fixed the issue, thanks. – Movak Aug 20 '14 at 17:18
-
1WARNING: If you use Enterprise and send mail for multiple Mandrill accounts, be sure to disable "Maintain connection to mail server" or all messages will be sent using the first authenticated Mandrill account. I wish Adobe had considered using a whitelist of mail servers to enable this feature for instead of a blind "all or nothing" approach. – James Moberg Dec 04 '15 at 14:42
-
1If you want to keep "maintain connections" enabled, set up different CNAME DNS records that points to Mandill's SMTP server. ColdFusion will identify it as a different mailserver (based on the name) and uniquely keep the connection open. More info here http://stackoverflow.com/questions/13481713/coldfusion-cfmail-and-sendgrid – James Moberg Dec 04 '15 at 14:55