A Clojure library that abstracts the GMail API (not the IMAP) interface.
Clojure HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
resources
src/gmail_clj
test/gmail_clj
.gitignore
LICENSE
README.md
project.clj

README.md

gmail-clj

A Clojure library designed to abstract the details of the GMail REST API: developers.google.com/gmail/api/

Installation

gmail-clj is available as a Maven artifact from Clojars:

Usage

Require the library in your REPL:

  (require '[gmail-clj.core :as gmail])

...or in your project.clj file

  (ns my-app.core
    (:require [gmail-clj.core :as gmail]))

Be sure to set your Google API Application Key and Secret:

  (gmail/set-client-secret! "aaaaa")
  (gmail/set-client-id! "bbbbbb")
  (gmail/set-refresh-token! "ccccc")
  (gmail/set-access-token! "dddddd") ; Optional. If you already have an access token.

Authorizing

This library takes your API information and will do an authorization based on a refresh token. (Note: If your app doesn't request a refresh token, you can simply set the access-token with gmail/set-access-token!, but we can't re-authorize after that token expires without a refresh token.)

To generate the refresh token you need to write your own interface with the Google OAuth endpoint, but for development and testing I've included an HTML file that does the basic OAuth handshake and returns the refresh token: /resources/index.html.

To Do

Here's a few things I haven't gotten to yet, mostly because I didn't need them in my specific use case. If you'd like to dive in an help on these, that would much appreciated!

  1. Sending email is very basic at the moment (to, subject, body): no bcc, no cc, no multiple addresses bcc / cc / to.
  2. All endpoints are hard-coded to the "me" authorized email identifier at this time.
  3. Email attachments!!

License

Copyright © 2014 Mike Flynn / @thatmikeflynn

Distributed under the Eclipse Public License, the same as Clojure.