Mandrill

We use Mandrill to send transactional email (eg. password reset emails, notifications, etc) from our staging and dev environments.

Using Mandrill in your dev environment
If you are working on an email-related story you will probably want your local dev machine to send email and all that. Chances are your dev machine doesn't have a mail server set up, and even if it did, your IP address would probably be on a spam blacklist (especially if it is your home DSL or something like that). So, one useful option is to use Mandrill, the same way Growstuff's live site does. Another benefit of this is that you get reporting on whether the email was actually delivered.

You will need access to a Mandrill username and API key to do this. That means:


 * you are a committer with access to growstuff-dev on Heroku, OR
 * you have set up your own Mandrill account, possibly as described below (for your own Heroku app) or independently of Heroku.

The following notes assume you're a committer with access to growstuff-dev, but if you have your own Mandrill/Heroku setup then you should be able to translate quite easily.

First, find the username and API key.


 * Go to http://heroku.com and login
 * Click on Apps
 * Go to growstuff-dev
 * Under addons, you should see Mandrill listed. Click on it.
 * A page should open showing the Mandrill admin interface
 * In the upper right (but not the *very* upper right, as that's the Heroku interface -- we're talking about the upper right of the Mandrill part of the screen... yeah, I know) click on the settings menu that looks like a cog wheel. Under there, you should see "SMTP and API credentials".  Click on that.
 * Note down the SMTP username (something@heroku.com) and the API key (further down the page)

Now, when you run  on your local machine, pass these as environment variables, like so:

MANDRILL_USERNAME=blah MANDRILL_APIKEY=blah rails s

If you prefer not to have to do this all the time, you can set the environment variables in your shell config files (.bashrc or equivalent) so they are always available to you.

NOTE: Never disclose Growstuff's Mandrill username/API key anywhere public, or people could use it to send spam through our account, costing us money and reputation. Don't commit them to github, don't send them on the mailing list, etc.

Initial setup on Heroku (historical notes)
Here are some notes from when we first set it up on Heroku, which you might want to follow if you ever have reason to set up a new app with Mandrill support.

Follow steps here: https://devcenter.heroku.com/articles/mandrill


 * first, verify your account (i.e. add a credit card) via https://heroku.com/verify -- note that first 12,000 emails are free so for low usage you won't be charged anything
 * In my case, it didn't seem to set the MANDRILL_APIKEY config so I did this:
 * choose "SMTP", then click "Add API key"
 * copy-paste the username and api key and do this:  (replacing as needed)
 * should now return the API key you just set
 * I edited  to send email through Mandrill, committed (locally), pushed to heroku with   (heroku_environments was the branch I was working on) and voila, it worked!
 * Note that all this uses a heroku-specific Mandrill account, which is separate from the Mailchimp/Mandrill account we already had in Growstuff's name. Oh well.
 * I edited  to send email through Mandrill, committed (locally), pushed to heroku with   (heroku_environments was the branch I was working on) and voila, it worked!
 * Note that all this uses a heroku-specific Mandrill account, which is separate from the Mailchimp/Mandrill account we already had in Growstuff's name. Oh well.