Enabling iPhone push emails on your Ubuntu mail server

The iPhone does not support the IMAP Idle protocol to receive push notifications for new emails. Fortunately the open source project Z-Push implements the ActiveSync protocol which can be also used by iOS to receive push email notifications.

If you followed my other articles on how to install a mail server on Ubuntu, you have a running Dovecot server. You also need a running Apache server with PHP5. The server has to respond to https requests. If your server meets these requirements, adding Z-Push to this setup is easy.

Download the latest Z-Push version from here. At the time of writing the most recent version is 2.1.0.

Now install necessary Ubuntu packages:

aptitude install php5-cli php5-imap php-soap

Unpack Z-Push and move the folder into your https directory:

tar -xvzf z-push-2.1.0-1750.tar.gz
mv z-push-2.1.0-1750 /var/www/vhosts/YOUR_DOMAIN/httpsdocs/z-push
chown -R www-data.www-data /var/www/vhosts/YOUR_DOMAIN/httpsdocs/z-push

Z-Push needs two additional working directories:

mkdir /var/lib/z-push /var/log/z-push
chown www-data.www-data /var/lib/z-push /var/log/z-push

Now it’s time to modify the Z-Push configuration file config.php. You only need to set the timezone and the backend provider. Anything else can be left on default.

define('TIMEZONE', 'Europe/Berlin');
define('BACKEND_PROVIDER', 'BackendIMAP');

The last step is to set an alias address to the z-push folder in the Apache virtual host configuration:

Alias /Microsoft-Server-ActiveSync /var/www/vhosts/YOUR_DOMAIN/httpsdocs/z-push/index.php

You can test if the server is setup properly by opening the url https://YOUR_DOMAIN/Microsoft-Server-ActiveSync in the browser. You will be prompted for username and password. After you enter your login credentials, the server will answer GET not supported. If you get this message, you are all setup.

On the iPhone you now have to create a new Exchange mail account and you are done.

Leave a Reply