views:

1146

answers:

7

Does anyone know of an open source PHP class (preferably BSD or MIT license) that will interface with the MS Exchange Server 2007 Web Services via. SOAP?

I am looking for a higher level class that has functionality for sending messages via. the web service.

A: 

Exchange server supports WebDAV:

http://www.troywolf.com/articles/php/exchange_webdav_examples.php

If all you want to do is send messages, you could just use SMTP:

http://ca2.php.net/manual/en/book.mail.php

RussSchick
I have SMTP working with NLTM auth. but the message isn't saved in the Sent items. I assume WebDAV would save this in the Sent Items and send then message.
Luke
A: 

I have been researching this same issue and I have yet to find a class specific to MS Exchange. However, if you feel up to learning and building the XML yourself, you may want to have a look at the NTLM SOAP classes at http://rabaix.net/en/articles/2008/03/13/using-soap-php-with-ntlm-authentication. This will allow you to authenticate against Active Directory to make your SOAP calls, which native PHP SOAP does not allow you to do. Another decent resource that uses the same method to connect to MS CRM is http://www.reutone.com/heb/articles_internet.php?instance_id=62&actions=show&id=521.

JamesArmes
A: 

The examples under http://www.troywolf.com/articles/php/exchange_webdav_examples.php are for Exchange 2003 not 2007.

A: 

Did anyone find a good PHP class that interfaces with Exchange 2007 in some way, SOAP perhaps?

This is not an answer...
Jordan Ryan Moore
No I have not yet found an appropriate Exchange 2007 PHP class.
Luke
A: 

Here is a class that you need: php-ews (This library makes Microsoft Exchange 2007 Web Services easier to implement in PHP). You could find it at: http://code.google.com/p/php-ews/

There is only one example but that should give you the way to implement it. Below you can find an implementation in order to:

  • connect to server
  • get the calendar events

Note: don't forget to fill-in blank variables. You would also need to include php-ews classes files (I used the __autoload PHP function).

$host = '';
$username = '';
$password = '';
$mail = '';
$startDateEvent = ''; //ie: 2010-09-14T09:00:00
$endDateEvent = ''; //ie: 2010-09-20T17:00:00

$ews = new ExchangeWebServices($host, $username, $password);
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;

$request->CalendarView->StartDate = $startDateEvent; 
$request->CalendarView->EndDate = $endDateEvent; 
$request->CalendarView->MaxEntriesReturned = 100;
$request->CalendarView->MaxEntriesReturnedSpecified = true;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;

$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;   
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $mail;
$response = $ews->FindItem($request);
echo '<pre>'.print_r($response, true).'</pre>';
Rev
A: 

Can you post an example of how exactly you used ___autoload to load the php-ews classes.

Sorry, I'm pretty new to PHP, don't quite understand how this works.

Tom
Know this isn't an answer - the answer doesn't allow for comments :|
Tom
+1  A: 

I had this same problem, so I started building something, here:

http://github.com/rileydutton/Exchange-Web-Services-for-PHP

It doesn't do much yet (basically just lets you get a list of email messages from the server, and send email), but it would be good enough to use as a basic starting point for doing some more complicated things.

I have abstracted out a good bit of the complexity that you would have to slog through using php-ews. If you are looking to do some raw, powerful commands with the server, I would use php-ews...this is for folks who just happen to be working with an Exchange server and want an easy way to do some basic tasks.

Oh, and it is MIT licensed.

Hope that someone finds it useful!

Riley Dutton