The greatest challenge to any thinker is stating the problem in a way that will allow a solution

Bertrand Russell

By

On 5 Mar 2012

Zimbra

Tags: , , ,


A while back I played with getting ActiveSync working for my Zimbra server using Z-Push (see previous post here), which was OK, but due to the lack of HTML email sync support and the fact that it seemed likely that v7 the Zimbra Appliance (ZCA) was to be released soon (free for 10 accounts with ZimbraMobile, Zimbra’s implementation of ActiveSync), I never really got round to using it anger.

But having plumped for v7, ZCA seemed to be taking an age to come out of Beta (it still is). Z-Push v2 is expected to be released at some point this year, though that does seem to be slipping (see roadmap), which will feature HTML support; but regardless there’s a branch version of v1 that implements HTML email sync anyway.  Therefore, I’m back to playing with Z-Push.

I’ve managed to get it up and working, and have been syncing and sending email without issue for a few weeks, and have sync’ed the odd calendar and contact item as well; using one of my email accounts.  Here’s how you can get it done…

Background

Z-Push is an open source ActiveSync solution, primarily designed to work with Zarafa, it will work with most email solutions directly through IMAP, and can also use 3rd party interfaces (known by Z-Push as backends) in order to access email data.  Obviously Active Sync is about more than just email, and Z-Push aims to sync all those other data types (contacts, calendar, tasks etc – though note that there are some limitations depending on what device you’re using, see the compatibility list).

ActiveSync is presented to a device (phone, smartphone, PDA etc) over HTTP(S), and Z-Push is written in PHP in order to present the ActiveSync protocol to the device and interact with your email / groupware / collaboration server.  Interaction with Zimbra is done via the Zimbra backend which accesses Zimbra’s SOAP API. Whilst you can install Z-Push on the same server as Zimbra, you have to hack Zimbra in order to redirect the ActiveSync traffic away from Zimbra (which is also using HTTP(S) for the user web client).  Which means that you’re best off running Z-Push on its own web-server, at least until you’ve got it running and are confident in how it works, before you start destroying your Zimbra server.

Set-Up

The procedure below assumes you have a working web-server (running Apache in my case – I’ve used Apache and web-server interchangeably in the procedure), with access to your Zimbra server (over HTTPS, TCP 443).  The web-server needs to be accessible to the internet (so it can be accessed from your devices).  It doesn’t cover provisioning (because I haven’t set it up myself), if I do, I’ll post up my experiences.

All of the configuration below is carried out on your web-server, with Z-Push being placed in /var/www/z-push/…

 

  1. If you don’t have them, install subversion (to download the required software with) and php-curl (allows web-server to interact with Zimbra server)
    • apt-get install subversion php5-curl
  2. Create a folder for Z-Push on your web-server
    • mkdir /var/www/z-push
  3. Download the Z-Push Active-Sync 12.1 branch to the folder
    • svn checkout svn://svn.berlios.de/z-push/branches/as12.1 /var/www/z-push
  4. Download the Zimbra Active-Sync 12.1 backend branch into a /zimbrafolder
    • mkdir /var/www/z-push/zimbra
    • svn checkout https://zimbrabackend.svn.sourceforge.net/svnroot/zimbrabackend/zimbra-backend/branches/as12.1 /var/www/z-push/zimbra
  5. Move unrequired files out of backend, leaving only backend.php and diffbackend.php (Z-Push pre-loads everything in backend, so you want to keep the contents to a minimum)
    • mkdir /var/www/z-push/backend-old
    • mv /var/www/z-push/backend/* /var/www/z-push/backend-old
    • mv /var/www/z-push/backend-old/backend.php /var/www/z-push/backend/
    • mv /var/www/z-push/backend-old/diffbackend.php /var/www/z-push/backend/
  6. Move the zimbra.php file into backend
    • mv /var/www/z-push/zimbra/zimbra.php /var/www/z-push/backend/
  7. Allow write access to the state folder
    • chgrp www-data /var/www/z-push/state
    • chmod g+w /var/www/z-push/state
  8. Create file for debug to go to
    • touch /var/www/z-push/debug.txt
    •  chmod 777 /var/www/z-push/debug.txt
  9. Update the config.php file as required (see example below)
  10. Create an Apache2 config file for the Active-Sync website (see below for example config), and enable
    • EG vi /etc/apache2/sites-available/z-push
    • EG cd /etc/apache2/sites-enabled
    • EG ln -s ../sites-available/z-push z-push
    • service apache2 restart

Config.php

# Update the following existing config lines
date_default_timezone_set("Europe/London");                # Or use whatever Unix style time-zone that's appropriate for you
define('PROVISIONING', false);
$BACKEND_PROVIDER = "BackendZimbra";
 
# Add the following config lines
define('ZIMBRA_DEBUG',true);
define('ZIMBRA_URL', 'https://mysserveraddress.com');      # Update with you Zimbra server hostname
define('ZIMBRA_USER_DIR', 'zimbra');
define('ZIMBRA_SYNC_CONTACT_PICTURES', true);
define('ZIMBRA_VIRTUAL_CONTACTS',true);
define('ZIMBRA_VIRTUAL_APPOINTMENTS',true);
define('ZIMBRA_VIRTUAL_TASKS',true);
define('ZIMBRA_IGNORE_EMAILED_CONTACTS',true);
define('ZIMBRA_HTML',true);

Apache config:

The example config below is for an unsecured transport layer, meaning traffic between your devices and the Z-Push server could be snooped, to set-up over HTTPS see my Wiki

VirtualHost *:80>
        ServerAdmin info@as.domain.com
        ServerName  as.domain.com

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/z-push/
        Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php

        <Directory />
                AllowOverride All
        </Directory>

	php_flag magic_quotes_gpc off
	php_flag register_globals off
	php_flag magic_quotes_runtime off
	php_flag short_open_tag on

        # Logfiles - you'll need to create the paths if they don't exist already
        ErrorLog  /var/log/apache2/z-push/error.log
        CustomLog /var/log/apache2/z-push/access.log combined

 </VirtualHost>

In theory, it should be working now, in order to test that basic connectivity and interaction between the components (Zimbra, backend and Z-Push) is OK…

  1. Browse to your server, eg http://as.domain.com/Microsoft-Server-ActiveSync(replace ‘as.domain.com’ with the hostname or IP address of your Z-Push server)
    • You should be prompted for a username and password (for an account on your Zimbra server)
    • If not, there’s a problem with your Apache config.  If you had to install extra components (eg php-curl), try restarting Apache.
  2. Enter a valid Zimbra user/pass
    • You should get a “GET not supported” page (see right), in which case you’ve tested authentication through Z-Push, the Zimbra backend, to your Zimbra server

Next step is to attempt to sync from a device for an account to allow some further testing.  Once you’ve created an account on your device, give it a few mins to do a first sync.

If things aren’t working as expected…

  1. Check the web-server logs for any errors.
    • You shouldn’t be seeing any, especially PHP errors.  Double check your config.
  2. Check the Z-Push debug.txt log for errors.
    • Admittedly, this isn’t the most intuitive, and my log shows the odd error despite everything working OK.  Try to ascertain whether your problem is Z-Push based, or Zimbra backend based.
  3. Search the Zimbra backend forum thread – Z-Push Zimbra Backend – Zimbra :: Forums (don’t post random questions)
  4. Use the Zimbra backend support tracker – SourceForge.net: Z-Push Zimbra Backend: Support Requests (you can open a request here)
  5. Use the Z-Push form – z-push.net • Index page

 

If you notice any problems with the above, if I could have made it clearer somewhere, or any other comments that might be of use; please let me know!


9 Comments to “Z-Push (v1 with HTML ActiveSync) for Zimbra FOSS”

  1. kolomalo says:

    “z-sync” on apache config files must be “z-push”
    It’s all right?

  2. kolomalo says:

    And Apache don’t start until I created /var/log/apache2/z-push dir

    • Simon Strutt says:

      Not sure if Apache would fail to start, but you do need to create if it doesn’t exist, have updated the post to make that more obvious – thanks for the feedback.

  3. kolomalo says:

    I follow exactly every step, but when I enter the URL, Apache show a 404 error :/

    Any idea?

    Thanks for your work!

    • Simon Strutt says:

      Check the Apache error log just in case there’s anything of interest but probably more likely a problem in the Apache config.

      Check the Alias line (eg Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php), and that the file /var/www/z-push/index.php exists

  4. kolomalo says:

    Hi.

    The only way that made it works was eliminates virtualhosts and add Alias option only.

    Thanks!!!!!

  5. vmtest says:

    Doest this z-push can modyfi the mysql zimbra structure?

    If yest , that it is dangerous for ZCS 7.x ?

    • Simon Strutt says:

      Z-Push doesn’t interact with the Zimbra MySQL instance – it uses the Zimbra SOAP interface which is a fully supported method of interaction. It’s actually recommended that you don’t install Z-Push onto the same server as Zimbra, as you will have to hack the Zimbra install so that Active-Sync web requests get handled by Z-Push rather than the Zimbra web interface. As long as you don’t do that, there is no risk involved for your Zimbra service.

Leave a Reply

XHTML: You can use these tags if you know what they are: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.