There are two possible approaches to creating a "development" API key in Mandrill, which serve different use cases:
Create a Test Key. No emails sent using this key will actually be sent. This is the simplest approach, and appropriate if your testing flow doesn't require you to actually receive your test emails. (You can still see the content of the emails that would have been sent in the Outbound tab.)
Create a live API key, and use the Rules Engine to make it so that emails sent with this key will be automatically rejected unless the recipient address matches some pattern. You should use this approach if your testing flow requires actually receiving the emails you send - for example, if you have an automated end-to-end test of your password reset functionality.
Approach 1: Using Test Mode
Test Mode was added to Mandrill in 2013. To use it, first create a Test Key from the API Keys subsection of the SMTP & API Info section of the Settings tab. The first key you create here will always be a live key, but if you click "New API Key" a second time, you will be able to choose to create a test key:
Once you've done that, "send" some emails using the Test Key (the emails won't actually be sent) and click the Turn on test Mode option from the dropdown menu at the top-right of the screen:
While the admin panel is in Test Mode, if you go to the Outbound tab you will be able to see emails you've asked Mandrill to send with your test API key, as if they had really been sent.
Approach 2: Using the Rules Engine
First, create a new live API key from the API Keys subsection of the SMTP & API Info section of the Settings tab. You must give the key a Description, or you will not be able to refer to it from the Rules Engine.
Next, go to the Rules section of the Outbound tab and click "Add Rule":
From the Rules interface, set up a rule that will reject emails if the API key is your test key and the recipient's email matches some pattern of your choosing. The pattern could be a single email address like testbot@yourdomain.com
, or it could be an entire domain, like *@yourdomain.com
.
In case you want to craft your own, complicated pattern, note that per the docs, Mandrill uses Python's fnmatch module to match your patterns against email addresses (which uses glob syntax, which you may be familiar with from your shell if you use Unix).
Emails you send using this key to domains matching your pattern will really be sent and show up in the live Outbound tab. Ones that don't match the pattern will not be sent and will show up as "rejected" in the live Outbound tab.