Push Email on your iPhone for free

One of the great advantages of having an Exchange server is that you can use ActiveSync to push emails to your iPhone ( or other ActiveSync enabled device).

This means that emails will show up on your iPhone almost as soon as they arrive in your mail providers Inbox.

Now this is great if you can afford and or have the know how to run a full on Microsoft Exchange Server.

If you’re only managing one or two accounts it might be more cost effective to use Z-Push

Here’s what we need to pull this off.

  1. An IMAP enabled mailbox (I’ll be using Gmail)
  2. An Apache web server
  3. PHP and a couple PHP Modules
  4. A device that supports ActiveSync (I’ll use an iPhone)
  5. A Linux box to run this all on (I’ll use Ubuntu for these instructions)
  6. Z-Push. This is the magic piece

First things first make sure you have Linux and Apache installed and working.

One you have Apache up and working we can begin.For these instructions I’ll be using Ubuntu Intrepid Ibex.

Install php-mail and php5-imap

sudo apt-get install php5-imap php-mail

Now we need to get Z-Push

for that head on over to http://z-push.sourceforge.net/soswp/

Now lets continue on and install Z-Push

open up your terminal and move to the directory you downloaded Z-Push to and uncompress the package

tar zxvf ./z-push-1.2.tar.gz

you’ll now have a z-push folder you can move this to a more appropriate location I moved my copy to /var/www/webaccess

mv ./z-push /var/www/webaccess/.

Make sure the z-push folder is owned by the Apache user

sudo chown -R /var/www/webaccess/z-push

Now we need to create an alias in our Apache config for Z-Push as follows.

Alias /Microsoft-Server-ActiveSync /var/www/webaccess/z-push/index.php

In my case I put this line in the /etc/apache2/sites-enabled/000-default file. It can go anywhere within the <VirtualHost> </VirtualHost> tags

Now restart Apache

sudo /etc/init.d/apache2 restart

Finally we need to configure Z-Push to check our IMAP mailbox

open the Z-Push config file

nano /var/www/webaccess/z-push/config.php

The Lines we need to change are as follows

$BACKEND_PROVIDER = “BackendIMAP”;

define(‘IMAP_SERVER’, ‘imap.gmail.com’);

define(‘IMAP_PORT’, 993);

define(‘IMAP_OPTIONS’, ‘/notls/norsh/ssl/novalidate-cert’);

define(‘IMAP_DEFAULTFROM’, ‘username’);

If you’re using another IMAP server you can change the

define(‘IMAP_SERVER’, …. and  define(‘IMAP_PORT’,….. lines to reflect your IMAP server

After altering these lines you can save the file exit then restart Apache again

sudo /etc/init.d/apache2 restart

And thats it you should now be able to point your ActiveSync device like your iPhone or iPod Touch at your Apache server and that’s it you now have push mail. One caveat is that you’ll have no contact/calendar sync via this connection.

If you have any questions, corrections or comments please leave them below in the comments.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Published by

LiamM

I'm a self labeled Nerd who enjoys Playing Video Games, restoring classic muscle cars (i have a 65' Mustang in the works) , Running Big Data Clusters, Tattoos, Working on System Automation, Riding and customizing Motorcycles, and writing python Code. I'm an SRE with DemonWare/Activision Specializing in Big Data/Hadoop operations but all opinions and views expressed on this site are solely my own.