Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (40 sloc) 2.19 KB


Mailchimp::Mandrill is a simple API wrapper for the Mailchimp Mandrill API.


A MailChimp account and a Mandrill specific API key.

Note, to be able to send messages, you'll have to click an e-mail in a message sent to you the first time you try to use that sender.


There are a few ways to use Mandrill.

You can create an instance of the API wrapper:

mandrill ="your_api_key")

You can set your api_key globally and call class methods:

Mailchimp::Mandrill.api_key = "your_api_key"

You can also set the environment variable 'MAILCHIMP_MANDRILL_API_KEY' and Mandrill will use it when you create an instance:

mandrill =

To check if your api_key is valid:


Sending a message

Send a message so a single email:

response = mandrill.messages_send({
    :message      => { 
        :subject => 'your subject', 
        :html => '<html>hello world</html>', 
        :text => 'hello world', 
        :from_name => 'John Smith', 
        :from_email => '', 
        :to => ['']

Calling other methods is as simple as calling API methods directly on the Mandrill instance (e.g. mandrill.users_verify_sender(...)). Check the API documentation) for more information about API calls and their parameters.

Plugging into ActionMailer

You can tell ActionMailer to send mail using Mandrill by adding the follow to to your config/application.rb or to the proper environment (eg. config/production.rb) :

config.action_mailer.delivery_method = :mailchimp_mandrill
config.action_mailer.mailchimp_mandrill_settings = {
      :api_key => "your_mailchimp_mandrill_apikey",
      :track_clicks => true,
      :track_opens  => true, 
      :from_name    => "Change Me"

These setting will allow you to use ActionMailer as you normally would, any calls to mail() will be sent using Mandrill

Something went wrong with that request. Please try again.