Posted in: haskell.
Today I’m releasing the mandrill package for interfacing with the Mandrill API. In case you don’t know what Mandrill is, is an API-based service for sending transactional emails. The free plan ships with a free and attractive quota of 12k email a month, which makes it a cheap solution for small-medium businesses.
The package per se is not rocket science: it just ships a bunch of boilerplate to be able to send and receive JSON from Mandrill. On top of this tough:
The library scratches my own itches, namely be able to send quickly and easily an email message using Mandrill. Pull Requests are certainly welcome, please fork away!
Using the built-in transformer is as easy as:
{-# LANGUAGE OverloadedStrings #-}
import Text.Email.Validate
import Network.API.Mandrill
main :: IO ()
= do
main case validate "foo@example.com" of
Left err -> print $ "Invalid email!" ++ show err
Right addr -> runMandrill "MYTOKENHERE" $ do
let msg = "Hello from Haskell"
<- sendEmail (newTextMessage addr [addr] "Hello" msg)
res case res of
MandrillSuccess k -> liftIO (print k)
MandrillFailure f -> liftIO (print f)
Astute readers will notice I have used the email-validate package from Hackage. Even though I like the fact you are forced to validate your email before sending them out, I also feel this might become burdensome on the long run. I’m open to feedback here.
The package is available on Hackage as we speak:
cabal install mandrill
Enjoy! Alfredo