Configure Mandrill as mail server and GMAIL as mailbox
What do you do when a client of yours ask for a mailbox? Some developers prefer to buy mailboxes on their domain providers (1-5$ year/mailbox), others are so experienced in postfix and unix administration that can configure a mail server in 5 minutes. I sincerely hate handling mailboxes. They are long to configure, i don’t like self-hosted web interfaces like roundCube and i hate to spend time to fine-tune the server in order to avoid black lists and spam.
So i come up with this revelation:
let’s use something like Mandrill which has a huge free tier to handle personal emails.
I expected to find tons of material to support my idea or some critical issue that destroys it completely… but actually i found a little and i was able to make it working perfectly!
What i did was:
- I created a Mandrill account and API keys
- I set my MX records to point to
@ 10 30653071.in1.mandrillapp.com. @ 20 30653071.in2.mandrillapp.com.
- I set the additional records to validate my domain:
mandrill._domainkey.jonathanargentiero.com v=DKIM1; k=rsa; p=...
spf v=spf1 include:spf.mandrillapp.com ?all
- I started sending emails to my mandrill account
The result at this point was that Mandrill was receiving my emails, but it was not letting me to use their backend interface as a mailbox (eheh!). So i thought: “well use GMAIL”, but to use it i need to forward them to GMAIL so:
- I created a PHP project hosted on my server connected with the Mandrill API with the duty to forward inbound emails to the outbound service.
- I enabled web hooks for Inbound emails to that URL (when an inbound email arrives send the data to that URL)
So the final result was:
1. EMAIL ARRIVES AT MANDRILL INBOUND 2. MANDRILL SENDS DATA TO MY-WEBSERVER 3. MY-WEBSERVER PROCESS DATA AND SEND IT BACK TO MANDRILL OUTBOUND 4. MANDRILL OUTBOUND FORWARDS THE EMAIL TO MY-GMAIL-ADDRESS
Since Mandrill offers SMTP addresses to send mail and Gmail offers the alias management through confirmation email everything went smoothly and now i am enable to handle infinite mailboxes from my gmail inbox.
After that i worked a little and made a Github project that you can find here: https://github.com/jonathanargentiero/mandrill-inbound-outbound-forward-php
With some nice configuration options and quick install guide.
I probably can’t see some drawbacks of this method, but i was able to configure 5 domains in few minutes on a single gmail mailbox.
Rather nice, don’t you think?