Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Example Configuration

Francisco Miguel Biete edited this page Mar 16, 2014 · 7 revisions

We will configure Z-Push-contrib, step by step, so you will get a functional ActiveSync server with IMAP, CardDAV and CalDAV functionality.

In others page you will learn to configure the HTTP server, PHP backend or DAViCal.

If you want to contribute with another server or configuration feel free to it.

Configuration Description

In your Z-Push-contrib you will find a lots of config.php files. One file for each backend and another one in the root foolder as the main configuration.

Remember to never commit and push your config.php files.

Main (Basic) Configuration

This file (/config.php) contains the main configuration for Z-Push-contrib. We will only change some parameters, but you can look across the file for more options, it's pretty well documented.

define('TIMEZONE', '');

Here we will put our timezone. You will find the supported list in PHP Timezones

define('TIMEZONE', 'Europe/London');

define('LOGLEVEL', LOGLEVEL_INFO);

This parameter will set the log detail. It's safe to leave it as LOGLEVEL_INFO in a production system.

define('LOGLEVEL', LOGLEVEL_INFO);

$specialLogUsers = array();

I use this option with my testing users. The users in this array will have a more detailed log, and in individual files. Pretty nice to debug in production.

$specialLogUsers = array("[email protected]","[email protected]");

define('BACKEND_PROVIDER', '');

Here we will choose the backend to use.

define('BACKEND_PROVIDER', 'BackendCombined');

Combined Configuration

This is the most difficult file to edit (backend/combined/config.php)

You will find something like this:

return array(
        //the order in which the backends are loaded.
        //login only succeeds if all backend return true on login
        //sending mail: the mail is sent with first backend that is able to send the mail
        'backends' => array(
            'i' => array(
                'name' => 'BackendIMAP',
            ),
            'z' => array(
                'name' => 'BackendZarafa',
            ),
            'm' => array(
                'name' => 'BackendMaildir',
            ),
            'v' => array(
                'name' => 'BackendVCardDir',
            ),
            'c' => array(
                'name' => 'BackendCalDAV',
            ),
            'l' => array(
                'name' => 'BackendLDAP',
            ),
            'd' => array(
                'name' => 'BackendCardDAV',
            ),
        ),
        'delimiter' => '/',
        //force one type of folder to one backend
        //it must match one of the above defined backends
        'folderbackend' => array(
            SYNC_FOLDER_TYPE_INBOX => 'i',
            SYNC_FOLDER_TYPE_DRAFTS => 'i',
            SYNC_FOLDER_TYPE_WASTEBASKET => 'i',
            SYNC_FOLDER_TYPE_SENTMAIL => 'i',
            SYNC_FOLDER_TYPE_OUTBOX => 'i',
            SYNC_FOLDER_TYPE_TASK => 'z',
            SYNC_FOLDER_TYPE_APPOINTMENT => 'z',
            SYNC_FOLDER_TYPE_CONTACT => 'z',
            SYNC_FOLDER_TYPE_NOTE => 'z',
            SYNC_FOLDER_TYPE_JOURNAL => 'z',
            SYNC_FOLDER_TYPE_OTHER => 'i',
            SYNC_FOLDER_TYPE_USER_MAIL => 'i',
            SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'z',
            SYNC_FOLDER_TYPE_USER_CONTACT => 'z',
            SYNC_FOLDER_TYPE_USER_TASK => 'z',
            SYNC_FOLDER_TYPE_USER_JOURNAL => 'z',
            SYNC_FOLDER_TYPE_USER_NOTE => 'z',
            SYNC_FOLDER_TYPE_UNKNOWN => 'z',
        ),
        //creating a new folder in the root folder should create a folder in one backend
        'rootcreatefolderbackend' => 'i',
    );

You will replace it with something like this:

return array(
        //the order in which the backends are loaded.
        //login only succeeds if all backend return true on login
        //sending mail: the mail is sent with first backend that is able to send the mail
        'backends' => array(
            'i' => array(
                'name' => 'BackendIMAP',
            ),
            'c' => array(
                'name' => 'BackendCalDAV',
            ),
            'd' => array(
                'name' => 'BackendCardDAV',
            ),
        ),
        'delimiter' => '/',
        //force one type of folder to one backend
        //it must match one of the above defined backends
        'folderbackend' => array(
            SYNC_FOLDER_TYPE_INBOX => 'i',
            SYNC_FOLDER_TYPE_DRAFTS => 'i',
            SYNC_FOLDER_TYPE_WASTEBASKET => 'i',
            SYNC_FOLDER_TYPE_SENTMAIL => 'i',
            SYNC_FOLDER_TYPE_OUTBOX => 'i',
            SYNC_FOLDER_TYPE_TASK => 'c',
            SYNC_FOLDER_TYPE_APPOINTMENT => 'c',
            SYNC_FOLDER_TYPE_CONTACT => 'd',
            SYNC_FOLDER_TYPE_NOTE => 'c',
            SYNC_FOLDER_TYPE_JOURNAL => 'c',
            SYNC_FOLDER_TYPE_OTHER => 'i',
            SYNC_FOLDER_TYPE_USER_MAIL => 'i',
            SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'c',
            SYNC_FOLDER_TYPE_USER_CONTACT => 'd',
            SYNC_FOLDER_TYPE_USER_TASK => 'c',
            SYNC_FOLDER_TYPE_USER_JOURNAL => 'c',
            SYNC_FOLDER_TYPE_USER_NOTE => 'c',
            SYNC_FOLDER_TYPE_UNKNOWN => 'i',
        ),
        //creating a new folder in the root folder should create a folder in one backend
        'rootcreatefolderbackend' => 'i',
    );

We have removed the unused backends (we don't want them loaded, so yeah remove them!!).

And we have associated the object types with the correct backend (messages: imap, contacts: carddav, task,note,journal,appointment: caldav).

IMAP Configuration

Now it's the turn for the BackendIMAP (/backend/imap/config.php)

define('IMAP_SERVER', 'localhost');

Your IMAP server

define('IMAP_SERVER', 'imap.domain.com');

define('IMAP_PORT', 143);

The IMAP port

define('IMAP_OPTIONS', '/notls/norsh');

Connection options, if unsure leave it alone.

define('IMAP_DEFAULTFROM', '');

If your users don't set the FROM header in the messages sent... But it's safe to leave blank.

define('IMAP_SENTFOLDER', '');

The Sent folder name. It's better to leave blank.

define('IMAP_INLINE_FORWARD', true);

If false, your forwarded messages will be in an attached .eml file. I preffer to have the forwarded messages behind my text.

define('IMAP_EXCLUDED_FOLDERS', '');

List of folders you will ignore in your IMAP server. For example I ignore the sieve rules folder, and the spam.

define('IMAP_EXCLUDED_FOLDERS', 'dovecot.sieve|spam');

define('IMAP_SMTP_METHOD', 'mail');

The send method used for your user messages. You can use mail here if your server has Postfix as MTA.

$imap_smtp_params = array();

Options for the SMTP method selected. My preffered choice is mail, so no options here.

CalDAV Configuration

BackendCalDAV configuration is short and simple (/backend/caldav/config.php)

define('CALDAV_SERVER', 'http://calendar.domain.com');

Server URL.

define('CALDAV_PORT', '80');

Server port.

Remeber to change http:// by https:// in the CALDAV_SERVER if your port is SSL.

define('CALDAV_PATH', '/caldav.php/%u/');

The path until your calendar. %u will be replaced with the username and %d with the domain.

define('CALDAV_PERSONAL', 'home');

Calendar.


For example I have a fixed calendar for every user

https://calendar.domain.com/caldav.php/[email protected]/work/

So my configuration would be

define('CALDAV_SERVER', 'https://calendar.domain.com');
define('CALDAV_PORT', '443');
define('CALDAV_PATH', '/caldav.php/%u/');
define('CALDAV_PERSONAL', 'work');

CardDAV Configuration

BackendCalDAV configuration is more complex, but easy enough (/backend/carddav/config.php)

define('CARDDAV_PROTOCOL', 'https');

What protocol is used in your server: http or https.

define('CARDDAV_SERVER', 'localhost');

Server name

define('CARDDAV_PORT', '443');

Server port

define('CARDDAV_PATH', '/caldav.php/%u/');

Server path to the addressbook, or the principal that contains the addressbooks If your user has more than 1 addressbook point it to the principal.

Example: user [email protected] will have 2 addressbooks
http://localhost/caldav.php/[email protected]/addresses/personal
http://localhost/caldav.php/[email protected]/addresses/work
You set the CARDDAV_PATH to '/caldav.php/%u/addresses/' and "personal" and "work" will be autodiscovered

%u: will be replaced with the username %d: will be replaced with the domain Remember to add the trailing /

define('CARDDAV_DEFAULT_PATH', '/caldav.php/%u/addresses/');

Server path to the default addressbook. Mobile devices will create new contacts here. It must be under CARDDAV_PATH for every user.

%u: will be replaced with the username %d: will be replaced with the domain Remember to add the trailing /

define('CARDDAV_GAL_PATH', '/caldav.php/%d/GAL/');

Server path to the GAL addressbook. This addressbook is readonly and searchable by the user, but it will NOT be synced. If you don't want GAL, comment it.

%u: will be replaced with the username %d: will be replaced with the domain Remember to add the trailing /

define('CARDDAV_GAL_MIN_LENGTH', 5);

Minimal length for the search pattern to do the real search. So if you put here 5, the server will only give a response after you input 5 letters in your mobile device.

define('CARDDAV_CONTACTS_FOLDER_NAME', '%u Addressbook');

Addressbook display name, the name showed in the mobile device. You can put whatever you want here.

%u: will be replaced with the username %d: will be replaced with the domain

define('CARDDAV_SUPPORTS_SYNC', false);

If the CardDAV server supports the "sync-collection" operation.

  • DAViCal supports it, and it's faster, so set it to true if that's your server.

  • SabreDav, Owncloud and SOGo don't support it, so set it to false.

    Setting this to false will work with most servers, but it will be slower: 1 petition for all the hrefs, and 1 petition for each vcard. If you can, open a enhacement petition for your server.

define('CARDDAV_SUPPORTS_FN_SEARCH', false);

If the CardDAV server supports the FN attribute for searches.

  • DAViCal supports it

  • SabreDav, Owncloud and SOGo don't.

    Setting this to true will search by FN. If false will search by sn, givenName and email. It's safe to leave it as false.

define('CARDDAV_URL_VCARD_EXTENSION', '.vcf');

If your carddav server needs to use file extension to recover a vcard.

  • Davical needs it.
  • SOGo official demo online needs it, but some SOGo installations don't need it, so test it.

For example SOGo configuration for the online demo would be:

define('CARDDAV_PROTOCOL', 'http');
define('CARDDAV_SERVER', 'sogo-demo.inverse.ca');
define('CARDDAV_PORT', '80');
define('CARDDAV_PATH', '/SOGo/dav/%u/Contacts/');
define('CARDDAV_DEFAULT_PATH', '/SOGo/dav/%u/Contacts/personal/');
define('CARDDAV_GAL_PATH', '/SOGo/dav/%u/Contacts/GAL/');
define('CARDDAV_GAL_MIN_LENGTH', 5);
define('CARDDAV_CONTACTS_FOLDER_NAME', '%u Addressbook');
define('CARDDAV_SUPPORTS_SYNC', false);
define('CARDDAV_SUPPORTS_FN_SEARCH', false);
define('CARDDAV_URL_VCARD_EXTENSION', '.vcf');