Sending email from Clojure.

I’m working on several small projects in Clojure, and for one of them I needed to be able to send email.  Quick googling revealed this.  Java Mail API?  Just what I wanted.  However since I’m using leiningen, I needed to find a maven repository with javamail.  In my search for javamail I happened across Apache commons-email, the description is as follows: “Commons Email aims to provide a API for sending email. It is built on top of the Java Mail API, which it aims to simplify.“  Simplify you say?  Well that is worth a look…  Long story short, if you are using leiningen.  In project.clj add:


:repositories [["central-proxy" "http://repository.sonatype.org/content/repositories/central/"]]
:dependencies [[org.apache.commons/commons-email "1.2"]]

Now you can simply do the following:

This does add one extra dependency but, considering it can easily send HTML email and do attachments, I think it’s worth it.

Notes