Introduction: why I needed Z-Push
A few day’s ago, I set up my own mail server. Why? Because I wanted a cool looking mail adres, because I wanted better spam filtering, because I wanted multiple accounts (so I can make a new one each time I sign up somewhere), because I could and because the tutorial explaining it looked real nice.
Everything was great and I was very happy with my set-up… except for one thing. The gmaill app on my Android phone only polled for new mails every 15 minutes! This was the lowest poll time I could set!! Clearly unacceptable. If only there was some way to push the mails instead. Enter Z-Push.
Z-Push is an open-source implementation of the Microsoft Exchange ActiveSync protocol, which is natively supported by Android. Using this protocol with the gmail app enables Push e-mail.
Setting up Z-Push (aka D-push on Debian)
In this ‘tutorial’, I’ll assume that you already set up the mail (and optionally other) backends. If you haven’t I recommend these absolutely great tutorials by workaround.org. This was also the tutorial I used to set up my mail server.
When I started setting up Z-Push, I immediately noticed that most tutorials were a bit outdated. They also installed Z-Push by downloading it from the site, rather than using the package provided in the repository (called d-push, due to rebranding). Furthermore, I could only find only one tutorial explaining how to do this with Apache. I decided this would make a great blog post.
So lets begin. The first thing we’ll need to do is install Z-Push (duh!). Simply use the command
apt-get install d-push. Don’t worry about the name difference: Debian merely rebranded it on trademark grounds but it’s the exact same thing. During the installation you may get asked which webserver should be automatically reconfigured for Z-Push. You can select whichever you prefer, but this tutorial is written specifically for setting up Z-Push with Apache.
After this, edit the file
/usr/share/z-push/config.php using your favorite text editor. You can read through the file yourself and set the options as you like, but I changed the following settings. In the “Default settings” section I changed the timezone setting to
define('TIMEZONE', 'Europe/Paris');. In the “BackendIMAP settings” subsection located in the “Backend settings”, I set
define('IMAP_PORT', 993); and
Now we need to modify the Apache configuration. To do so, create a new file called
d-push.conf in the
/etc/apache2/conf-available/ directory. Next, use your favorite text editor and add the following content to the file:
<Directory /usr/share/d-push> php_flag magic_quotes_gpc off php_flag register_globals off php_flag magic_quotes_runtime off Order allow,deny Allow from all AddType application/x-httpd-php .php </Directory> Alias /Microsoft-Server-ActiveSync /usr/share/d-push/index.php
Now, all that’s left is to enable the configuration using the
a2enconf d-push command and reloading apache with
service apache2 reload.