GithubHelp home page GithubHelp logo

isabella232 / mimi_mailer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from madmimi/mimi_mailer

0.0 0.0 0.0 198 KB

A tiny simple Ruby library that interacts with Mad Mimi's transactional mailing API.

License: MIT License

Ruby 100.00%

mimi_mailer's Introduction

MimiMailer

This gem provides a simple low-frills way to send transactional emails using the Mad Mimi Mailer API. If you need more, please check out our full-sized madmimi gem.

Installation

Add this line to your application's Gemfile:

gem 'mimi_mailer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mimi_mailer

Usage

If you aren't using bundler,

require "mimi_mailer"

and then configure the mailer to use your Mad Mimi API settings.

MimiMailer.configure do |config|
  config.username = "[email protected]"
  config.api_key  = "your_api_key"
  config.default_from_address = "your default from address" # optional -- will use your username if not configured
end

Then, create a mailer class that subclasses MimiMailer::Base and implements a delivery method like so:

class UserWelcomeMailer < MimiMailer::Base
  from_address '[email protected]' # A class-specific from address

  def self.deliver(user)
    mail(promotion_name: 'promotion_name', to: user.email, subject: "subject", body: { name: user.name })
  end
end

MimiMailer::Base.mail

MimiMailer::Base.mail accepts the following options:

{
  # Required. The name of the Mad Mimi promotion you want to send
  promotion_name: 'promotion_name',

  # Required. Who you want to send the email to. Also may be specified with :recipient.
  to: '[email protected]',

  # Who you want the email to be from. If not specified, this will fall back to the
  # class-specific from address or the configured default_from_address
  from: '[email protected]',

  # The subject of the email
  subject: 'A nice email',

  # Placeholders that will be merged into a composed promotion on Mad Mimi. :raw_html
  # and/or :raw_plain_text may be specified instead (see below)
  body: {
    first_name: user.first_name,
    last_name: user.last_name
  }
}

MimiMailer::Base.bulk_mail

MimiMailer::Base.bulk_mail accepts the following options:

{
  # Required. The name of the Mad Mimi promotion you want to send
  promotion_name: 'promotion_name',

  # Required. The name of the audience list to import into and send to.
  audience_list: 'audience_list',

  # Required. The email recipients list in CSV format. Also may be specified with :csv_file.
  to: "email,first name,last name,car\n[email protected],Dave,Hoover,Ford\n[email protected],Colin,Harris,Chevy",

  # Who you want the email to be from. If not specified, this will fall back to the
  # class-specific from address or the configured default_from_address
  from: '[email protected]',

  # The subject of the email
  subject: 'A nice email',

  # Placeholders that will be merged into a composed promotion on Mad Mimi. :raw_html
  # and/or :raw_plain_text may be specified instead (see below)
  body: {
    first_name: user.first_name,
    last_name: user.last_name
  }
}

Email body

The email contents can be specified using either:

:body

The body hash contains keys and values that will be substituted into correspoding promotion placeholders.

or

:raw_html

The raw HTML body of the email. May be used in conjunction with :raw_plain_text.

:raw_plain_text

The raw plain text body of the email. May be used in conjunction with :raw_html.

Please take a look at our transactional email API guide for more information about these and other options.

mimi_mailer's People

Contributors

jbrowning avatar sorich87 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.