Push email on Linux

December 11th, 2008 / 13 Comments »

Since I’m a gadget ponce I do like to keep up with the Joneses, and while MobileMe does fancypants push email which quite literally shoves your messages into the quivering bowels of your phone, my normal email address doesn’t. This made me sad, and I found that my relationships and life in general suffered as a result of it. I started using drugs and self-harming, and soon spiralled down to the absolute nadir of squalor and self-loathing. This is generally considered to be a bad thing.

Mercifully the one thing I did have left as I hit skid row was my own mailserver, and today I found a snazzy thing called Z-Push which turns your mailserver into a PUSH mailserver. How exciting!

For the benefit of those who’d like to attempt to get this working, here’s a quick guide, courtesy of my words:

What you’ll need:

  • A Linux box. Mine is running Debian Etch, so these instructions lean heavily in that direction. Being PHP it probably runs on other platforms too, but I don’t care.
  • An IMAP server. I use Dovecot.
  • A web server. Apache2 is good and nice and fun.
  • A bit of spare time. Half an hour should do
  • One delicious hand-rolled cigar
  • First of all download the latest version of Z-Push from here. In your shell go to /var/www and extract the tarball to /var/www/z-push. This is important. Don’t put it anywhere else or you will incur the wrath of Ganesh the elephant god.

    If you don’t have it already, install PEAR:

    apt-get install php-pear

    Make sure you have the PEAR Mail plugin:

    pear install Mail

    And also install PHP5-IMAP:

    apt-get install php5-imap

    Now edit the config.php file. You’ll have to change the location of PEAR in the first few lines. The standard config.php gives it as:

    "/usr/share/pear"

    Debian installs it in /usr/bin, so change this to:

    "/usr/bin/pear"

    Further down in the config.php file you’ll need to change $BACKEND_PROVIDER to point to your IMAP server:

    $BACKEND_PROVIDER = “BackendIMAP”;

    Assuming your IMAP server is on the same machine, you shouldn’t need to change anything else. Save and exit. While we’re hear, let’s have a little chuckle to ourselves about the term ‘backend provider’.

    Now we need to make a small change to your Apache2 configuration files. The Z-Push install notes suggest making this change in httpd.conf, but since I use virtual domains I keep all my Alias settings in apache2.conf. You’ll need to add the following line:

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

    Restart Apache2:

    /etc/init.d/apache2 force-reload

    Everything should now be working. In your web browser go to http://example.com/Microsoft-Server-ActiveSync and you should be asked to sign in. Use valid login details for your IMAP server, and you should be greeted by an error:

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

    This is perfectly normal, and if you don’t see this error you have done something terribly wrong.

    Now all you need to do is connect your mobile device to your server using standard IMAP login details and your standard server name. While most devices will have an entry for a domain this is ignored, so leave it blank if you can or type in any old rubbish. It’s worth noting at this point that SSL will only work if your website is configured to use SSL, so if it isn’t you’d best untick that option on your mobile device.

    Now, smoke your damn cigar. It is done.

    Have fun, and don’t bother me if it doesn’t work.

    Update: If you’re using an iPhone and find that all messages are being marked as read, there’s a simple fix here.


    13 Comments on “Push email on Linux”

    1. 1 John Daniels said at 6:22 pm on December 11th, 2008:

      I just don’t understand the obsession with push email.

      I had Nokia and Windows Mobile phones which supported IMAP IDLE, which Dovecot supports.

      It just meant that I got instant notification of all the spam I get every day. Who cares about that?

      I tell Mail on my iPhone to check every half an hour. Anything that’s more urgent than that someone can find my phone number and call me.

    2. 2 Simon J. James said at 6:34 pm on December 11th, 2008:

      I read everything n this email and my iphone still DOES NOT make me seem attractive in the slightest.

      You are a SCOTCH FRAUD and I want my money back unless you say my jeans are nice.

    3. 3 Rodti said at 6:40 pm on December 11th, 2008:

      @Simon Are those jeans you’re wearing?

    4. 4 Simon J. James said at 10:10 pm on December 11th, 2008:

      I painted my legs blue for YOU.

    5. 5 Rodti said at 11:14 am on December 12th, 2008:

      @Simon They’re lovely.

    6. 6 Rodti said at 11:16 am on December 12th, 2008:

      @John I’m far too impatient and hate having to refresh mail clients, so it works for me. That said, it’s probably running my battery down like nobody’s business.

    7. 7 undertruck said at 10:23 pm on January 1st, 2009:

      Is it possible to set it up on shared servers (mine is bluehost)? I can’t access many of those files. Thanks.

    8. 8 Rodti said at 10:48 am on January 2nd, 2009:

      @undertruck It all depends on what Bluehost allow you to mess with. Being a shared host I’d expect they probably have the necessary PHP and PEAR modules as they’re reasonably popular. If you have your own instance of Apache2 then you should be okay, because that alias is crucial!

    9. 9 Haraye said at 3:00 am on March 16th, 2009:

      This may not be revelant but i figured i’d post this anyway. If you’re using ubuntu 8.10 you may be in for some issues with the network manager. For some unknown reason it stops functioning. You will need to manually set you’re resolv.conf with your ISP’s DNS servers. That file is located in /etc/network/resolv.conf

    10. 10 Herman D. HugeLoad IV said at 12:05 pm on June 6th, 2009:

      If I push email into the shuddering nether regions of my iPhone it gets all funny and experiences some kind of digital orgasm, then switches itself off, which is most FUCKING CONVENIENT.

      So, I decided – in lieu of getting a CrackBerry – to just KEEP ON USING GMAIL WHICH IS QUITE OK THANKYOUVERYFUCKINGMUCH.

      In summary then: bollocks

    11. 11 idem said at 3:34 pm on December 10th, 2009:

      Hi Rodti,
      I installed z-push…it seems to work fine, but it doesn’t really push mail.
      I had to manually schedule sync…that it’s not push mail.
      Can you help me?
      I can make a manually sync, a scheduled sync, but not pushed.. :(

    12. 12 rodti said at 3:38 pm on December 10th, 2009:

      What phone are you using? Setting it up as an Exchange account on iPhone I didn’t have to worry about scheduled syncing and push worked straight away.

      Try the Z-Push forums – lots of knowledgeable people on there!

    13. 13 Malcom Saetteurn said at 5:21 pm on March 19th, 2010:

      Ahhh — I had to read it twice, but it finally made sense :o )


    Leave a Reply