Skip to content

Z-Push: Setting Up an ActiveSync Server with Postfix (or How to Set Up Push Mail)

Introduction

Push server technology is very trendy nowadays, especially with the iPhone which now allows connections (just like Windows Mobile) to an Exchange-like push server. The problem is that for the open-source world, Exchange is not an option. I found a well-developed project on SourceForge called Z-Push that works perfectly with Postfix.

Installation

We'll download the latest version from https://z-push.sourceforge.net and extract it to /var/www:

tar zxvf z-push-<version>.tar.gz -C /var/www

Now we'll apply the proper permissions:

1
2
3
chmod 777 /var/www/z-push/state
chmod 755 /var/www/z-push/state
chown www-data. /var/www/z-push

Configuration

Apache

We need to configure Apache to redirect /Microsoft-Server-ActiveSync to /var/www/z-push/index.php. There are two options:

  • Using alias:
Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php
  • Using VirtualHost

Add this to your virtualhost configuration (/etc/apache2/sites-enabled/000-default):

1
2
3
4
5
6
       <Location /z-push>
               Options Indexes FollowSymLinks MultiViews
               Order allow,deny
               allow from all
               RedirectMatch ^/Microsoft-Server-ActiveSync /var/www/z-push/index.php
       </Location

PHP

Now we need to make some modifications to your PHP configuration:

1
2
3
4
php_flag magic_quotes_gpc off
register_globals off
magic_quotes_runtime off
short_open_tag on

Restart the Apache server:

/etc/init.d/apache2 restart

Z-Push

Now we just need to edit a few fields in the configuration:

1
2
3
4
5
6
7
...
date_default_timezone_set("Europe/Paris"
...
$BACKEND_PROVIDER = "BackendIMAP";
...
define('IMAP_SERVER', 'deimos.fr');
...

Now, you just need to test your configuration by connecting to your server: http:///Microsoft-Server-ActiveSync
If you get a login/password prompt, enter your IMAP account credentials, and if you get this message, it means it's working :-)

GET not supported
This is the z-push location and can only be accessed by Microsoft ActiveSync-capable devices.

FAQ

I have problems but don't know where they're coming from, how can I debug?

Simply create a debug file:

touch /var/www/z-push/debug.txt
chmod 777 /var/www/z-push/debug.txt