Giter VIP home page Giter VIP logo

mandrill_dm's Introduction

Mandrill DM

Build Status Gem Version security Code Climate

Mandrill DM allows you to use ActionMailer with the Mandrill API. Created by Jonathan Berglund and maintained by John Dell, and Kirill Shnurov and various contributors.

Rails Setup

First, add the gem to your Gemfile and run the bundle command to install it.

gem 'mandrill_dm'

Second, set the delivery method in config/environments/production.rb.

config.action_mailer.delivery_method = :mandrill

Third, create an initializer such as config/initializers/mandrill.rb and paste in the following code:

MandrillDm.configure do |config|
  config.api_key = ENV['MANDRILL_APIKEY']
  # config.async = false
end

NOTE: If you don't already have an environment variable for your Mandrill API key, don't forget to create one.

Rails 3: see Rails 3 (Mail 2.5) support

Available configuration options

Option Default value Description
api_key Mandrill API key.
async false Enable a background sending mode that is optimized for bulk sending.

Mandrill Templates

If you want to use this gem with mandrill templates you just have to add the template param to the mail function and set the body param to empty string ''.

We use template instead of template_name as described in mandrill documentation since template_name it's used by ActionMailer.

class MyMailer < ActionMailer::Base
  def notify_user(email)
    headers['Reply-To'] = '[email protected]'
    mail(
      to: email,
      from: '[email protected]',
      body: '',
      template: 'your-mandrill-template-slug',
      template_content: [ # optional
        {
          name: 'header', # the name of the mc:edit editable region to inject into
          content: 'string to replace a mc:edit="header" in your template', # the content to inject
        },
        {
          name: 'content',
          content: 'string to replace a mc:edit="content" in your template'
        }
      ]
    )
  end
end

Development & Feedback

Questions or problems? Please use the issue tracker. If you would like to contribute to this project, fork this repository. Pull requests appreciated! Please ensure all specs and rubocop checks pass locally (run rake) and verify the travis build matrix passes.

This gem was inspired by the letter_opener and mandrill-delivery-handler gems. Special thanks to the folks at MailChimp and Mandrill for their Starter service and Ruby API.

Interactive Usage

$ irb -I . -r 'lib/mandrill_dm'

require 'pry'

mandrill_dm's People

Contributors

norbertszivos avatar spovich avatar genaromadrid avatar tensho avatar piotrze avatar jlberglund avatar brushbox avatar tomasc avatar kshnurov avatar dorongutman avatar duhast avatar januszm avatar ropiku avatar rossjourdain avatar ankurvyas-btc avatar dmatheron avatar beorc 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.