https://mandrill.com/ is an email delivery system which is ideal for use in web applications to send and receive emails. Mandrill is developed by Mailchimp, the company behind the very successful email marketing software at http://mailchimp.com/
In the past, I wrote a quick guide, with code samples on how to use Mandrill to send email templates designed in Mailchimp
Sending emails with Mandrill
Once you log in to your Mandrill account, click on ‘Settings’. This page shows you the SMTP credentials you will need to begin sending emails from your web application.
If you don’t see an SMTP password, you’ll need to generate an API key using the button below the existing SMTP. This becomes your SMTP password.
Take a note of the HOST, Port, SMTP Username and SMTP Password to use in your web application.
In your web application, update your SMTP details with the details from above and you’re ready to send.
Mandrill automatically adds any domain you use for sending through Mandrill to its control panel. Mandrill also automatically adds authentication to all messages sent through their servers, but adding SPF and DKIM records for your sending domain(s) is strongly recommended for better deliverability. You can do this by logging in to Mandrill and going to Settings->Domains to view and Test the DKIM and SPF instructions.
Receiving emails with Mandrill
To allow Mandrill to receive email on your behalf, log in to Mandrill and go to ‘Inbound’. If it is your first time using it, you will be asked to add a domain name first.
Once you add your domain, you will need to add 2 MX records to your domain name. This is to allow Mandrill to receive emails on your behalf. Press on ‘DNS settings’ for Mandrill to tell you the specific MX records to add. They will be in the format of :
To add these MX records, it depends on where you have purchased your domain name originally. Unfortunately, its outside of the scope of this guide to be able to give specific instructions for every hosting company, so in your own domain control panel, look for a DNS Settings section and add your MX records there. Once you have added your MX records, allow an hour or more for them to take effect and you can use the ‘Test’ button in Mandrill to make sure they are in place.
You can use a useful site http://mxtoolbox.com/ to check to see if your MX records are in place.
But what if I already have email DNS Records, such as Google apps set up on my domain?
This is a common scenario. It is likely that you already have some MX records in place for your business or personal emails and Mandrill’s new MX records won’t work well in this case.
To get around this, the solution is to create a new sub domain and add the MX records to that sub domain instead of the main domain name, so Mandrill doesn’t interfere with your regular emails.
For example, your normal emails could be using a domain name such as @domain.com. If you want to leave that alone for your personal or business emails, then set up a sub domain such as @app.domain.com. Notice the word ‘app’ that is now in the email address. The word can be anything you like, it is just a label of sorts to separate your normal emails from those that will be sent/received by your web application.
Once your MX records are in place..
The MX records allow Mandrill to receive emails. The next step is to to tell Mandrill what to do with those emails. The solution is to use ‘Routes’, this allows you to tell Mandrill where to send the emails it receives.
To create a new route, or edit existing ones, click on ‘Inbound’ and then click on ‘Routes’ next to the domain name you added earlier.
When adding a new route, you will be asked for the email address that you would like people to be able to email and also the URL to post to.
You can set the email address to ‘*’ to allow it to receive all emails to the domain name you have added, or else specify a particular email address if you prefer, such as ‘email@example.com’.
You will then need to tell Mandrill the URL to send your email to. A useful site to see what information Mandrill will send to your application is http://requestb.in. This site gives you a temporary URL which you can add as a route and tell Mandrill to send some test emails to it to seem them.
Once you are ready, set the URL to something in your web application, such as : http://mydomain.com/recieve_mandrill_email.
How you process the incoming email depends on the programming language you are using.
Here is some PHP/Codeigniter code you can use as a starting point to receive incoming email.