Tag: RackSpace

Parsing inbound emails with Mailgun, how to

Parsing incoming emails is a common task for many web application which deals with emails, and then take decision on the parsed contents. However, piping the incoming mail stream to an external script is not everyone’s food and it needs good knowledge on shell scripting and also you need to be good with your mail server to install/configure the pipe properly. So there are third party services out there which makes it easy for you by accepting your emails to predefined mailboxes. They also parse the email and post the content over HTTP to an external script (i.e webhook) which makes the whole process a lot easier. You just outsource the email parsing to these third party providers and spend time rather on analyzing the content of the email leveraging their email->http webhook. Cloudmailin, MailNuggets, and MailGun are one the few providers which I’ve tested and they work really good with very low latency. In this article I am going to show you how to configure your free Mailgun account to accept incoming mails, parse and then accept the mail content to your php script.

Step1: Register a free account with MailGun

Don’t worry – they dont charge. And Mailgun’s free plan is quite good with 200 mails/day which is pretty good during development phase. Once you are ready, you may opt in to purchase their plans which suit you best.

Step 2: Add a domain

Free accounts are restricted to use *.mailgun.org domain for now. So just log into you Mailgun control panel and create your own domain.

Configure your Mailgun Domain

Step 2: Create a mailbox to accept incoming mails

You need to configure a mailbox to start accepting inbound emails first, so you can process them later using different rules. Just go to your mailboxes tab in the Mailgun control panel and create a new mailbox.

Creating new Mailbox

Step 4: Link your incoming emails to your external script.

This step was a little confusing at first and I really didnt understand how to achieve the result. Mailgun will automatically parse these incoming mails, which you can filter by recipients or senders or by wildcard and then forward to your external script. To do that, just go to your Routes tab in the Mailgun control panel and create a new route, like the one shown in the screenshot below.

Configuring Routes and Linking to external scripts

See the forward() function does the job where my confusion began – I was almost clueless 😛

Ok we are done. Mailgun will now accept all mails to this mailbox [email protected] and parse the mail content including attachments, and then post the parsed contents as an array to the external PHP script we have configured in step 4. In your php script just capture those data from $_POST and do whatever you want to.

Shameless Plug

We develop beautiful dashboard and admin panel templates for the web application developers, which you can plug into your application easily. These templates comes with well documented code, even better documentation of components and a pack of essential plugins. Check out one of our admin template “Utopia” and grab your copy if you like it

Utopia Dashboard Template by Themio

 

Developing PHP applications in the cloud with these free cloud hosting providers

CPU and Disk-space are cheap these days. And the more cheaper they become, cloud companies are coming with more exciting deals for you. Some of them are offered in “Freemium” model, some of them are free forever and some of them are like trial plans which is free for a certain period of time. I will be focusing on some of these free cloud hosting options available out there. One thing to note before you proceed – these free cloud hosting options are very good to develop and test your applications (in dev+staging environment) and it may not be wise to deploy the production version of your application with any free plan (Except Amazon AWS’s free tier, its production ready).

Amazon AWS: Amazon AWS is not only a cloud hosting provider but there are LOT MORE under the hood. They offer you cloud servers, messaging gateway, payment service, CDN and many more. Now there is a sweet promotion going on for all new AWS customers. Just register a new account and you will be getting the followings for free, for ONE YEAR long. No catch!

  • 750 hours of Amazon EC2 Linux Micro Instance usage (613 MB of memory and 32-bit and 64-bit platform support) – enough hours to run continuously each month*
  • 750 hours of an Elastic Load Balancer plus 15 GB data processing*
  • 10 GB of Amazon Elastic Block Storage, plus 1 million I/Os, 1 GB of snapshot storage, 10,000 snapshot Get Requests and 1,000 snapshot Put Requests*
  • 5 GB of Amazon S3 standard storage, 20,000 Get Requests, and 2,000 Put Requests*
  • 15 GB of bandwidth out aggregated across all AWS services*
  • 25 Amazon SimpleDB Machine Hours and 1 GB of Storage**
  • 100,000 Requests of Amazon Simple Queue Service**
  • 100,000 Requests, 100,000 HTTP notifications and 1,000 email notifications for Amazon Simple Notification Service**
  • 10 Amazon Cloudwatch metrics, 10 alarms, and 1,000,000 API requests**

Now in above list ** means that upto this quota, it will always remain free forever, and * means that this service is free for one full year starting from the day of your registration.

Hosting on Amazon’s EC2 platform might be a little tiresome for completely new-comers who has limited knowledge on Linux, SSH and Private/Public key management but this article will help you to start quickly. This is one of the most lucrative among all others I will be mentioning in this article.

By the way, you need a valid credit card to register in Amazon AWS program.

PHPFog: There is a new kid in town, PHPFog. Though they are actually developed on top of Amazon’s AWS platform to help developers manage scaling, deploying etc in a painless and easy, everything under the hood style and they are doing good. PHPFog offers you 100MB of free hosting, 15 GB of bandwidth with unmentioned RAM and CPU for six months. No credit card is required to start. Moreover, they made it fairly easy for you to deploy any Zend-Framework or Drupal or Joomla or WordPress based application in the cloud with their pre-configured containers. This is really a decent package to kickstart developing an application 🙂

To start with PHPFog, you need to know git because source code deployment is completely managed using git and git hooks. You may also need to understand how to manage multiple SSH keypair in your machine to get started with PHPFog. Check out PHPFog at http://phpfog.com

PHPCloud This is something VERY new and I heard about it in last week, when one of my colleagues forwarded me the link. At this moment it is invitation based but dont panic, getting invitation will take hardly a day or two. PHPCloud is backed by Zend on top of Zend Application Fabric platform. Once you are done testing your application in phpcloud, you can keep it either here or deploy to other cloud providers like Amazon EC2, Rackspace or Rightscale. The configuration of the free tier is not mentioned but as far as I have heard, the free container will remain free forever. Please check out PHPCloud at http://www.phpcloud.com

Heroku: One of the prominent cloud platform provider for Ruby developers collaborated with Facebook last month and started providing free container to develop Facebook applications using PHP on top of their amazing platform. Heroku is good, reliable and it comes with thousands of add-on which you will need to buy while the core container is free for PHP Developers. Check out Heroku’s offer at devcenter.heroku.com/articles/facebook

I hope you find this article helpful for developing and hosting your php application in the cloud, and in the same time check the service they offered and their quality. Enjoy!

Shameless Promotion: If you are looking for any beautiful admin panel theme for your Web Application, then you can check out our Brand new and Shiny admin template Muse at Themeforest from our Themio team.

Muse, Professional and Responsive Admin Panel Template from Themio
Muse, Professional and Responsive Admin Panel Template from Themio

RackSpace Cloud Server Client Library for PHP

We, the developers at Leevio are currently developing an open source group collaboration application. We are using RackSpace Cloud servers since the very beginning of the development and we will also deploy in on rack space cloud.

As a part of our study we’d found that RackSpace provides excellent API to manage your cloud services. Unfortunately there are no language binding library released yet (for Cloud Server). But they’ve mentioned that they are developing one for python.

So we have spend our time for last two days and developed a PHP client library to use RackSpace cloud server API from inside a PHP application.

This client library is released under New BSD license. And is available to download/svn-checkout from it’s project page at http://code.google.com/p/phprackcloud/

There is plenty of documentation and example included. The code is mostly self explanatory. Please dont forget to check the Wiki page to get some idea on how to use this library and how far you can go. We have covered all available methods by RackSpace cloud server in our client library.

Happy clouding.

Project Page and Download: http://code.google.com/p/phprackcloud