Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
/ mimi_mailer Public archive

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

License

Notifications You must be signed in to change notification settings

madmimi/mimi_mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages