Giter Site home page Giter Site logo

mmemail's Introduction

MM-Email

Simple Clojure library for sending email, with just one jar!

Installation

Leiningen:

(defproject your-project "0.0.0"
  :dependencies [[mmemail "1.0.1"]]

Jar File

…can be downloaded at clojars.org/repo/mmemail/mmemail/1.0.1/mmemail-1.0.1.jar

Usage:

Include the library

(use 'mmemail.core)

The Easy Way

mmemail.core is the only include you need. It contains only 2 methods, the fist being send-email. It takes a map that includes all the configuration and email parameters. That’s it.

(send-email {:host "smtp.gmail.com"
             :port 465
             :ssl true
             :user "[email protected]"
             :password "runner"
             :to "[email protected]"
             :subject "Greetings"
             :body "Meep Meep!"})

Most of the parameters are required, but based on your server configuration you might get away without these:

  • :ssl

  • :password

  • :subject

It also accepts the following optional parameters:

  • :from (defaults to :user)

  • :cc

  • :bcc

The recipient parameters (:to, :cc, :bcc) may be a string, for one recipient, or a sequence of strings, for multiple recipients.

The Convenient Way

It can be annoying to pass such a big map into the function, and typically you’ll want to get all the server configuration out of the way. This is where the second function of mmemail.core (create-mailer) comes into play.

(def my_mailer (create-mailer {:host "smtp.gmail.com"
                               :port 465
                               :ssl true
                               :user "[email protected]"
                               :password "runner"}))

create-mailer will return a new function with all the configuration baked in. So in the future, you can send email like so:

(my_mailer {:to "[email protected]"
            :subject "Greetings"
            :body "Meep Meep!"})

The create-mailer accepts email parameters that will be used as defaults when the generated function is called.

(def my_mailer (create-mailer {:subject "Greetings"
                               :body "Meep Meep!"
                               :host "smtp.gmail.com"
                               :port 465
                               :ssl true
                               :user "[email protected]"
                               :password "runner"}))
(my_mailer {:to "[email protected]"})

License

Copyright 2010 Micah Martin. All Rights Reserved. MMEMail and all included source files are distributed under terms of the GNU LGPL.

mmemail's People

Contributors

slagyr avatar sjagoe avatar

Watchers

maran avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.