In this post I describe how to link together IMAP email, ownCloud calendar and contacts, Roundcube contacts, and set up access to all of them via any mobile device that supports ActiveSync. They don’t all need to be on the same server, but you will need to use the same username and password for IMAP and ownCloud.
I’m assuming that you already have an IMAP server, Roundcube install and ownCloud install set up and working. There are plenty of good online guides out there covering the installation of each component. This article aims to describe how to combine all of them together, as that was the step where I wasn’t able to find a decent set of instructions.
Roundcube contacts ⇔ ownCloud contacts
First, we’re going to link your ownCloud contacts to Roundcube using CardDAV. The instructions below assume that your Roundcube installation lives in
/usr/local/share/roundcube/, that you’re using MySQL for the backend, that your MySQL user is called
roundcubeuser and your database is called
roundcubedb. Replace these as appropriate using the values from your Roundcube’s
git clone https://github.com/blind-coder/rcmcarddav.git
mv rcmcarddav carddav
mysql -u roundcubeuser -p roundcubedb < mysql.sql(enter the MySQL password when prompted).
cp config.inc.php.dist config.inc.php
curl -sS https://getcomposer.org/installer | php
php composer.phar install
Now you need to edit the main Roundcube config file,
config/config.inc.php. You’ll need to find the
$config['plugins'] array and add
'carddav' to it. I also recommend editing
plugins/carddav/config.inc.php and setting
$prefs['_GLOBAL']['pwstore_scheme'] = 'encrypted'; so that your ownCloud password isn’t stored in a format that can easily be recovered. Now you should be able to log in to Roundcube as usual, go to Settings → CardDAV and enter the settings for your ownCloud install. The URL will look something like
https://example.com:443/owncloud/remote.php/carddav/addressbooks/username/contacts/ – you can find the exact address by logging into your ownCloud account, selecting Contacts in the top left, clicking the cog in the bottom left, and clicking on the CardDAV link icon (it looks like two links from a chain). Congratulations! Your contacts are now shared between Roundcube and ownCloud and any existing ownCloud contacts should now be visible in Roundcube.
Mobile device ⇔ IMAP & ownCloud
Now we will set up ActiveSync using Z-Push. This part is more involved. The instructions assume that you’re using Debian or Ubuntu, if not then you may need to adjust the paths, package names and usernames appropriately.
git clone https://github.com/fmbiete/Z-Push-contrib.git
mv Z-Push-contrib z-push
chown www-data /var/lib/z-push
apt-get install php5-xsl libawl-php
- Edit the Z-Push config files as described on https://github.com/fmbiete/Z-Push-contrib/wiki/Example-Configuration. The values below may be helpful.
The default ownCloud URLs for CalDAV are as follows:
The default ownCloud URLs for CardDAV are as follows:
Comment out the
Edit your Apache config to include the following:
Alias /Microsoft-Server-ActiveSync /usr/local/share/z-push/index.php
php_admin_value include_path .:/usr/share/php:/usr/share/pear:/usr/share/awl/inc:
If you’re not using mod_php5 then you’ll need to add
/usr/share/awl/inc to PHP’s
include_path by another means such as editing
php.ini. Finally, run
apache2ctl configtest to check that there aren’t any errors, and then
service apache2 reload to load the new config. You can test it by going to https://example.com/Microsoft-Server-ActiveSync in your browser. You should be prompted to enter your username and password. If these are entered correctly you should see a message saying GET not supported.
Assuming that worked, you’re now ready for the final piece of the puzzle: connecting your mobile device. The following instructions are for iOS devices, but similar steps will work on Android devices and Windows Phones.
- Open Settings.
- Select Mail, Contacts, Calendars.
- Select Add Account.
- Choose Exchange for the type.
- Enter your email address, password and account description.
- If you get a message saying “Cannot Verify Server Identity”, hit Cancel.
- Enter your server’s name in the Server field (e.g.
- Ignore the domain and re-enter your username and password.
- Press Next.
- Leave all the options (Mail, Contacts, Calendars, Reminders, Notes) selected and press Save.
To do: autodiscover
I spent a while trying to set up autodiscover, but kept running into the behaviour described in https://github.com/fmbiete/Z-Push-contrib/issues/165. Unfortunately that bug report references a configuration variable that is no longer used, so the workaround they describe doesn’t help anymore. When I work out how to fix the error I will update this article.