mailchimp/mailchimp-gem — pull request #4 by HighgrooveDan (2012-02-21 21:06:54+00:00)
Title: Maildrill can use api key from mail header

Hey guys, I'm working on a project that needs Devise to send emails via the Mandrill API. In working through that problem, I figured out how to get Devise to send an email with a custom ActionMailer::Base class, and I also figured out how to configure Rails to use the mandrill delivery handler. The problem encountered was specifying the api_key on a per-email basis, since the project I'm currently working on could have any number of api keys per mailchimp customer account. If I can solve that problem, I have a working solution!

I discovered that the best way to send this information into an action mailer delivery handler is to pass it in as a header on the message object itself. I saw that the MandrillDeliveryHandler did not currently support reading custom mail headers, so I sought to add that functionality in this pull request (and solve my problem above in the process).

The thing I am not sure on is how to test this. Any thoughts on testing? My first step was going to be to look at the Rails project itself and see how they tested the delivery handlers that come bundled with ActionMailer. Any other help or tips would be appreciated.

Thanks!