Configure Mandrill as mail server and GMAIL as mailbox
Hi everybody,
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?
Am I the only one that thinks that this is incredible?
I’m wondering if you’ve found any sticking points yet with your solution?
I have about 2 dozen clients and they all – every last one of them – loves Gmail but doesn’t want to pay $5/user/month.
This… cracks it, right? You’d be sending spam compliant emails, and receiving emails on one of the best spam filtering email servers out there.
It almost seems too good to be true. What am I missing?
Thanks!
Nothing much, with 2 dozen of clients it’s not that hard to manage but for example with 2 millions of clients you have a huge traffic going through your php server, which is undesiderable unless you plan to become a mail provider 😀
Anyway there is one major drawback that is I had no time to solve the “attachments” issue that i found (with my method i don’t receive attachments, I actually can see them when they arrive on my php server but then I fail to forward them to GMAIL).
To be used in production the following bug should be solved.
For the rest I found no big deals with the method. GMAIL is also able to identify spam sent to Mandrill (on one of my addresses I receive a lot of spam mails and they are filtered, but of course I never tried a 100% production environment with all kind of clients).
If you want to give it a test with you are clients tell us how it went.
It will also be great if someone makes me a pull request to fix the issue with attachments https://github.com/jonathanargentiero/mandrill-inbound-outbound-forward-php
I think for the attachment it needs to be an array, this might help
http://stackoverflow.com/questions/15213151/mandrill-email-attachments-file-path
https://mandrillapp.com/api/docs/messages.html#method=send
https://medium.com/@ethans/sending-emails-with-attachments-on-mandrill-c796cbf96b4f
Thank you!