Logon Functions — This section describes the various logon functions.
mapisession mapi_logon(string $profile,
string $password);
mapisession mapi_logon_zarafa(string $username,
string $password,
string $server);
mapisession mapi_logon_pst(string $filename);
mapimsgstore mapi_openmsgstore(mapisession $session,
string $entryID);
resource mapi_openentry(mapisession $session,
string $entryID,
long $flags);
mapitable mapi_getmsgstorestable(mapisession $session);
array mapi_openmsgstore_zarafa(string $username,
string $password,
string $server);
mapimsgstore mapi_openmsgstore_zarafa_other(string $entryid,
string $username,
string $password,
string $server);
mapisession mapi_logon(string $profile, string $password)
Logon to a MAPI profile
mapi_logon uses the MAPI calls MAPILogonEx(). Returns a mapisession object on success, FALSE on failure.
mapisession mapi_logon_zarafa(string $username, string $password, string $server)
Logon to a Zarafa server
mapi_logon_zarafa logs a user on to the server. A MAPI Session object is returned, which is required for further calls. This is the preferred method to logon to Zarafa. On failure, FALSE is returned.
mapisession mapi_logon_pst(string $filename)
Logon to a local MAPI PST-file
mapi_logon_pst makes a profile and uses the filename to store the information in a PST-file. You can open a specific PST file with this function, however, remember that only one process at a time can access a PST file. However, because the php-mapi extension shares sessions accross requests, you can open the same PST file across multiple PHP requests. Returns a mapisession object on success, FALSE on failure.
mapimsgstore mapi_openmsgstore(mapisession $session, string $entryID)
Opens a messagestore
The session is used to open a messagestore with the entryID given. Returns a mapimsgstore object on success, FALSE on failure.
When the entryid is a hexadecimal string, the function hex2bin must be used to convert the string to binary. Also the function bin2hex can be used to convert from binary to hexadecimal.
Example 3.19. Opening the stores of a Zarafa session
// $serverlocation is optional, default http://localhost:236/zarafa $session = mapi_logon_zarafa($username, $password, $serverlocation); $stores = mapi_getmsgstorestable($session); $storeslist = mapi_table_queryallrows($stores); $userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]); $publicstore = mapi_openmsgstore($session, $storeslist[1][PR_ENTRYID]);
resource mapi_openentry(mapisession $session, string $entryID, long $flags)
Opens an entry from a messagestore or addressbook.
This function works as mapi_msgstore_openentry but automatically detects from which store the message should be opened. It can also be used for EntryIDs in the addressbook and one-off EntryIDs. Because this function must open a store to get the item in that store, it is more efficient to use the mapi_msgstore_openentry function.
mapitable mapi_getmsgstorestable(mapisession $session)
Gets a table with the messagestores within the session.
Gets a table with the messagestores defined in the profile. The profile should be opened first with the function mapi_logon_zarafa. The table can be read with a mapi_table_* functions. Internally, this function calls the MAPI function GetMsgStoreTable(). Returns a mapitable object on success, FALSE on failure.
array mapi_openmsgstore_zarafa(string $username, string $password, string $server)
Opens an store for an existing Zarafa user.
Opens a store of a user on the Zarafa server. The result is either false, or an array of valid php resource id's which point to the userstore and the public store.
This function is depricated. Please use the mapi_logon_zarafa() function. This function will be removed in the future.
mapimsgstore mapi_openmsgstore_zarafa_other(string $entryid, string $username, string $password, string $server)
Opens an store for an existing Zarafa user. This function is depricated, and will be removed in the future.
Opens a store of a different user on the Zarafa server than which is known with username and password combination. This is actually a hack at the moment because of the limitations of mapi4linux (see source for more documentation). The result is either false, or a valid php resource id.
This function is depricated and will be removed in the future.
Example 3.22. Opening multiple Zarafa message stores
// usage example of depricated mapi_openmsgstore_zarafa_other(); $store = mapi_openmsgstore_zarafa("user","password"); $user2_entryid = mapi_msgstore_createentryid($store, "user2"); $user2_store = mapi_openmsgstore_zarafa_other($user2_entryid, "user", "password"); print_r(mapi_getprops($user2_store));
Example 3.23. Opening multiple Zarafa message stores
// normal MAPI way of opening other users store $session = mapi_logon_zarafa($username, $password, $serverlocation); $stores = mapi_getmsgstorestable($session); $storeslist = mapi_table_queryallrows($stores); $userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]); $publicstore = mapi_openmsgstore($session, $storeslist[1][PR_ENTRYID]); $user2_entryid = mapi_msgstore_createentryid($userstore, "user2"); $user2_store = mapi_openmsgstore($session, $user2_entryid);