Best way to access Exchange using PHP?

I am writing a CMS application in PHP, and one of the requirements is that it must be able to interact with the client’s Exchange server. I wrote this function several times earlier and always used WebDAV , but now I refuse it.

I will run the site in IIS or Apache (without preference) on a Windows 2008 server. A few things I will need to do include adding contacts to this user’s address book, sending emails as this user, and running contact reports for the user.

All this is quite simple to do with WebDAV, but if there is a better way that does not require any functionality that may be out of date in the near future.

Any ideas?

Update:

Justin, I like the idea of ​​using com objects, I'm just worried about maintaining a third product so that everything works ...

John, I can write a web service in C # to interact with these functions and access it using my PHP application, but this is also a bit out of the way.

Until now, I am not 100% sure that any of them is better than WebDAV ...

Can someone show me where I am stupid?

+49
windows php webdav exchange-server mapi
Aug 03 '08 at 0:03
source share
8 answers

I have not used PHP for this, but have experience using C # to achieve the same.

The Outlook API is a way to automate Outlook, not a direct connection to Exchange. I previously used this approach in a C # application and it works, although it may be a mistake.

If you want to connect directly to the Exchange server, you will need to explore the advanced MAPI.

In the past, I used this MAPIEx shell : Extended MAPI Wrapper .

This is a C # project, but I believe that you can use some .NET code on a PHP5 Windows server. Alternatively, it has a base C ++ DLL that you can use. I found this to be very good and there are some good sample applications.

Update:

Sorry for the delay, there is no current way to track messages.

I agree to add an extra layer to your application, and relying on third-party code can be scary (and rightly so).

Today I read another interesting post , labeled MAPI, which is on another subject. The main thing here, however, is that it is related to this important MS article . I still did not know about the problems of using managed code to interact with MAPI, although the C ++ code in the component should not be exposed to this error, since it is unmanageable.

This blog post also suggests other ways to connect to the MAPI / Exchange server. In this case, due to these new facts, http://us3.php.net/imap may be the answer suggested by another user.

+22
Aug 03 '08 at 7:50
source share

Is your client used with Exchange 2007? If so, I would take a look at Exchange Web Services . If not, then as much as possible, I think WebDAV is your best bet.

Personally, I don’t like using the route of the Outlook.Application COM COM object as its security requests ("The application is trying to access your contacts. Do you want to resolve this?", Etc.) can cause problems on the server. I also think it would be difficult to accomplish your tasks like impersonations using Outlook, for example, send mail as a given user.

+14
Aug 05 '08 at 2:35
source share

I can not recommend the Dmitry Streblechenko Redemption Data Objects library quite high. This is a COM component that provides a normal API for extended MAPI and is a joy to use. Exchange API columns move from one version to another: "Use M: drive! No, use WebDAV! No, use ExOLEDB! ... No, use web services!" with the only constant being the good old MAPI.

+8
01 Sep '08 at 20:33
source share

I released the open-source MIT licensed library that allows you to perform some basic operations in PHP using Exchange web services.

Exchange Web Services for PHP

I tested it only on Linux, but I see no reason why it will not work with installing Windows on PHP.

+7
May 4 '11 at 1:47 a.m.
source share

I'm not a PHP developer, but Google says that PHP 5+ can create COM components. If you can install Outlook in a field, you can write a PHP web service around a COM component to handle the requested requests.

$outlook = COM("Outlook.Application") 

Outlook API Link

+6
Aug 03 '08 at 3:07
source share

This Zarafa PHP MAPI extension looks as if it could work.

+5
May 09 '12 at 18:47
source share

I would look IMAP

IMAP, POP3, and NNTP

+4
Aug 04 '08 at 17:00
source share

I would recommend using PHP Exchange Web Services or short php-ews.

A fair amount of wiki documentation helped me a lot.

+2
Feb 01 '13 at 13:20
source share



All Articles