No release in over 3 years
Low commit activity in last 3 years
A Ruby API library for the Mandrill email as a service platform, forked to support json 2.0.2. Originally on https://bitbucket.org/mailchimp/mandrill-api-ruby/
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

< 1.0, >= 0.16.0
< 3, >= 1.7.7
 Project Readme

Mailchimp official gem

As of 2020, Mailchimp has an official gem for this: https://rubygems.org/gems/MailchimpTransactional

As of June 2023, this mandrill-api gem is working (and we are still using it), but I don't know how long that will stay true.

mandrill-api-ruby

mandrill-api-ruby is a fork of mandrill-api gem (src) with uptodate dependencies.

Original code here: https://bitbucket.org/mailchimp/mandrill-api-ruby/

Thanks to https://github.com/stellaservice/mandrill-api-ruby for fixing the json dependency.

Usage

in your Gemfile change

gem 'mandrill-api'

to

gem 'mandrill-api-json'

and run bundle install

How to check attachments in Test Mode on Mandrill

In order to retrieve Mandrill attachments in test mode the following script can be used:

require 'mandrill'
require 'base64'

def extract_attachments(email)
  attachments = []

  email['attachments'].each do |attachment|
    attachment_data = attachment['content']
    file_name = attachment['name']
    content_type = attachment['type']

    # Decode the attachment data from base64
    decoded_data = Base64.decode64(attachment_data)

    # Save the attachment to a file
    File.open(file_name, 'wb') do |file|
      file.write(decoded_data)
    end

    attachments << {
      file_name: file_name,
      content_type: content_type
    }
  end

  attachments
end

# Mandrill API key
mandrill_api_key = 'YOUR_MANDRILL_API_KEY'

# Mandrill message ID of the delivered email.
# You can find it in https://mandrillapp.com/settings/api, within the request of the email sent.
message_id = 'YOUR_DELIVERED_EMAIL_MESSAGE_ID'

# Initialize Mandrill client
mandrill = Mandrill::API.new(mandrill_api_key)

# Retrieve the message content using Mandrill API
message_info = mandrill.messages.content(message_id)

# Extract attachments from the message
attachments = extract_attachments(message_info)

# Print the extracted attachments
attachments.each do |attachment|
  puts "Attachment: #{attachment[:file_name]}"
  puts "Content Type: #{attachment[:content_type]}"
  puts "---"
end