rileydutton / exchange-web-services-for-php Goto Github PK
View Code? Open in Web Editor NEWA basic library for interacting with Exchange Web Services using PHP 5.
License: MIT License
A basic library for interacting with Exchange Web Services using PHP 5.
License: MIT License
hello,
i do an advance install. the wsdl will be not load if i don't declare the realPath of wsdl :
$exchangeclient = new ExchangeClient();
$exchangeclient->init("xxxx", "xxxx", null, realpath(dirname(FILE) . '/EWS/lib/Services.wsdl'));
$items = $exchangeclient->get_messages();
But when i use any functions of exchangeClient no data are retrieve.
which are the potential problem ?
my server is NTLM & Basic atuhentification and the url of my asmx services is an https,
i also must be pass to an proxy (entreprise architecture)
thans in advance
How to send emails with embedded images?
Thanks for this repo, it's great !!
Today I started to use this lib and have the following error:
PHP Notice: Undefined property: stdClass::$ToRecipients in Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 257
Reviewing I found this code block:
if(!is_array($messageobj->ToRecipients->Mailbox)) {
$messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
}
I see this object is referred in $messageobj in the line 241
When I get all keys, I get this:
MimeContent
ItemId
Subject
Sensitivity
Body
Attachments
Size
DateTimeSent
DateTimeCreated
ResponseObjects
HasAttachments
IsReadReceiptRequested
From
IsRead
I suppouse my Exchange Server not send some propertyes like ToRecipients, fot this reason I suggest check is ToRecipients is set before process it like this:
if (isset($messageobj->ToRecipients)) {
if(!is_array($messageobj->ToRecipients->Mailbox)) {
$messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
}
foreach($messageobj->ToRecipients->Mailbox as $mailbox) {
$newmessage->to_recipients[] = $mailbox;
}
}
Instead
if(!is_array($messageobj->ToRecipients->Mailbox)) {
$messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
}
foreach($messageobj->ToRecipients->Mailbox as $mailbox) {
$newmessage->to_recipients[] = $mailbox;
}
If im trying to run this library, i'm just getting back the following error:
Strict Standards: Creating default object from empty value in /var/www/exchange/lib/ExchangeClient.php on line 332
Strict Standards: Creating default object from empty value in /var/www/exchange/lib/ExchangeClient.php on line 333
Strict Standards: Creating default object from empty value in /var/www/exchange/lib/ExchangeClient.php on line 338
Strict Standards: Creating default object from empty value in /var/www/exchange/lib/ExchangeClient.php on line 340
Strict Standards: Creating default object from empty value in /var/www/exchange/lib/ExchangeClient.php on line 342
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 354
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 354
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 354
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 357
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 357
Notice: Trying to get property of non-object in /var/www/exchange/lib/ExchangeClient.php on line 357
So clearly somthing is wrong with the variable $CreateItem, but i'm not able to figure out what...
phpStorm shows me the useless error 'Undifined Variable "CreateItem"... '
Any Idea why this error occurred?
Is it possible, that this error has something todo with the, may not right configured, curl at the server?
Hey!
I've been trying to get this library working with my Exchange Server 2007. Unfortunately the basic installation didn't do anything for me. While the advanced installation got me a little further, I'm still having trouble and would appreciate any guidance. I saved the three files in the lib/ directory but running init() throws an error saying 'cannot load external entity'. If I hardcode the path 'http://localhost/lib/Services.wsdl' in ExchangeClient.php. I get the message:
'Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: 'ExchangeServices' already defined in ...'
Even though I definitely only posted the additional stuff only once and it's not in there a second time!
Can you help me out?
Thanks!!
// Edit: Actually, I was able to get it to work by putting the absolute filesystem path. However, now I'm getting a 401.2 HTTP error. Any clue why that's happening?
This only makes sense.. here is the code in the object:
public function get_events($start, $end) {
$this->setup();
$FindItem->Traversal = "Shallow";
$FindItem->ItemShape->BaseShape = "IdOnly";
$FindItem->ParentFolderIds->DistinguishedFolderId->Id = "calendar";
if($this->delegate != NULL) {
$FindItem->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $this->delegate;
}
$FindItem->CalendarView->StartDate = $start;
$FindItem->CalendarView->EndDate = $end;
$response = $this->client->FindItem($FindItem);
..................................
$FindItem isn't even defined or anything... so it's throwing the error about creating a default object from an empty value. Is there a better way to go about this? Instead of just doing:
$FindItem = new StdClass;
Because then it throws an error on line 95 ($FindItem->ItemShape->BaseShape) because then it becomes a multi-dimensional object... which would be tedious to make every single level an StdClass..
Thanks for any help.
Every time I call the function: $ec->init($username, $password); my webpage STOPS loading and remains white.
when I comment that line, everything is fine.
I even commented out the contents of the init() function and still the same white page.
Am I calling the init function wrong? Is there something I am missing?
PLEASE HELP!!!
and yes, all the necessary files are in the correct locations.
Thank you for this very useful peace of code!
Changes on ExchangeClient.php
'204,206c204
'<
'< $items = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Message;
'<
'---.
'>
'210c208
'< if(count($items) == 0)
'---
'> if($response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView == 0)
'212a211,212
'> $items = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Message;
'>
Hi,
when sending an email like so $ec->send_message("[email protected]", "Subject", "Content");
, the function returns 0 and print_r($ec->lastError);
shows ErrorMessageDispositionRequired
.
I was able work around this using $ec->send_message("[email protected]", "Subject", "Content", "Text", false);
but it would be nice if this worked even with $saveinsent = true
.
I believe the server I use runs Exchange 2013.
Thanks!
Hi,
I just wondered if someone could point me in the right direction on how to lookup room resources (or any type of resource) from a connection to Exchange using this library.
Within Outlook I can see room resources in my global address list but I'm not sure how you could hook into this using Exchange-Web-Services-for-PHP
.
Thanks
Apologies if this is a really simple problem but I have been trying to get this working for days and haven't been able to get past this hurdle. I have followed the setup instructions @ https://github.com/rileydutton/Exchange-Web-Services-for-PHP and when I run the test code on that page to send a simple email I get the below error
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\inetpub\wwwroot_Includes\EWS\lib\ExchangeClient.php on line 583
Any ideas?
Hi!
Everything is working but is it possible to access calendars in a public folder?
How?
Thanks!
Great script Riley....this script is exactly what I need and you did a great job of explaining things. However, I can't seem to get it to work. I followed the "advanced" installation verbatim but I keep receiving the following error when I run your example script...
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't bind to service in F:\UniServer\www\ExchangeWebServices\exchangeclient\Exchangeclient.php:38 Stack trace: #0 F:\UniServer\www\ExchangeWebServices\exchangeclient\Exchangeclient.php(38): SoapClient->SoapClient('Services.wsdl', Array) #1 F:\UniServer\www\ExchangeWebServices\exchangeclient\index.php(6): Exchangeclient->init('myusername', 'mypassword') #2 {main} thrown in F:\UniServer\www\ExchangeWebServices\exchangeclient\Exchangeclient.php on line 38
Here's my code:
require_once("Exchangeclient.php");
$exchangeclient = new Exchangeclient();
$exchangeclient->init("myusername", "mypassword");
$exchangeclient->send_message("[email protected]", "Subject", "A test message");
Any ideas on what might be going on? I'd love to get this working....thanks!
-K
Is there a way to get the client list (name and email) with PHP? I see that https://www.contactually.com has a way to import outlook contacts not having them export to CSV.
Hi,
I can get emails without error using get_message function. However, when I want to mark the read e-mail with the mark_message_as read function, I get the following error.
Severity: Error
Message: SOAP-ERROR: Encoding: object has no 'Path' property
Filename: lib/ExchangeClient.php
Line Number: 624 --> $response = $this->client->UpdateItem($request);
My code blocks like this:
$ec = new ExchangeClient();
$ec->init("xxxxx", "xxxxx", NULL, "http://myexchangedomain/EWS/Services.wsdl");
$result = $ec->get_messages('10', FALSE, 'inbox', TRUE);
$ec->mark_message_as_read( $result );
Hi,
Is there a newer version of this API that would allow me to connect to a Exchange Server 2013 to read/send emails. Also, add/view calendar event.
I apologize if this comment is in the wrong section.
SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'Services.wsdl' : failed to load external entity "Services.wsdl" in D:\xampp\htdocs\email\lib\NTLMSoapClient.php:9 Stack trace: #0 D:\xampp\htdocs\email\lib\NTLMSoapClient.php(9): SoapClient->SoapClient('Services.wsdl', Array) #1 D:\xampp\htdocs\email\lib\ExchangeClient.php(49): NTLMSoapClient->__construct('Services.wsdl', Array) #2 D:\xampp\htdocs\email\M2.php(14): ExchangeClient->init('oechslertc\supe...', 'Mdt12345') #3 {main}
As Microsoft wrote here, there will be some major changes Oct. 13, 2020.
"October 13th, 2020 we will stop supporting and fully decommission the Basic Authentication for EWS to access Exchange Online"
And this library uses the Basic Athentification am I right?
I'd like to create an event containing a body information as plain text or HTML. So i tried to extend the ExchangeClient function create_event() with:
$body = 'Hello World! This is a cool event :-)';
$CreateItem->Items->CalendarItem->Body = new StdClass();
$CreateItem->Items->CalendarItem->Body = $body;
$CreateItem->Items->CalendarItem->Body->BodyType = 'Text';
Therefore the resulting XML in the SOAP-request should look like this:
<t:Body BodyType="Text">Hello World! This is a cool event :-)</t:Body>
But no luck so far. I don't get what to assign to the body-object which contain the bodytext.
Hello. I'm trying to follow the instructions on page:
https://github.com/Heartspring/Exchange-Web-Services-for-PHP/blob/master/README.markdown
I have downloaded the files from my Exchange server. However, I can find no directory that contains the file ExchangeClient.php. Am I missing something?
I did find that the files I downloaded already exist in the wsdl directory. Are these dummy files that I should simply replace with the ones I downloaded (and then make the addition as suggested)?
Thanks for any help you can provide.
Hi,
I have setup $exchangeclient with advanced setup.
All events are created to calendar of delegate instead of target mailbox.
$exchangeclient = new Exchangeclient();
$exchangeclient->init
(
"[email protected]","adminpass",
"[email protected]",
"/path/in/my/server/Services.wsdl"
);
so all events are created to calendar of [email protected]
Any clues?
br, Marko Korhonen
Warning: stream_wrapper_unregister(): Unable to unregister protocol https:// in C:\xampp\htdocs\inventario\exchange\lib\ExchangeClient.php on line 485
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://mailcluster.fimitsgr.local/EWS/Services.wsdl' : Start tag expected, '<' not found in C:\xampp\htdocs\inventario\exchange\lib\NTLMSoapClient.php:8 Stack trace: #0 C:\xampp\htdocs\inventario\exchange\lib\NTLMSoapClient.php(8): SoapClient->SoapClient('https://mailclu...', Array) #1 C:\xampp\htdocs\inventario\exchange\lib\ExchangeClient.php(48): NTLMSoapClient->__construct('https://mailclu...', Array) #2 C:\xampp\htdocs\inventario\mail.php(8): ExchangeClient->init('helpdesk', 'Fenice_03', NULL, 'https://mailclu...') #3 {main} thrown in C:\xampp\htdocs\inventario\exchange\lib\NTLMSoapClient.php on line 8
If get_events() returns only one event an error is shown
Warning: count(): Parameter must be an array or an object that implements Countable in /Applications/XAMPP/xamppfiles/htdocs/pikettapi/sources/lib/ExchangeClient.php on line 121
Add
if($this->delegate != NULL)
$CreateItem->Items->Message->From->Mailbox->EmailAddress = $this->delegate;
to line 321 in Exchangeclient.php to fix.
Thanks a lot for a great piece of code.
Manteca
Thank you very much for doing this! It is very useful.
Some servers require NTLM and Basic authentication. In this case, the Authorization: NTLM header must be sent before the Authorization: Basic header.
Please consider adding an authorization_type to the class so affected users can use something like this:
401c401
< curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
> curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM | CURLAUTH_BASIC);
Hi.
No pull requests have been merged since 2017.
I also have few improvements made for my own use that could be useful but no one is merging code then I wont bother.
This class is awesome. It does exactly what I need it to do, without having to be an expert in using web services.
If you run this with:```
error_reporting(-1);
ini_set('display_errors','On');
You get all kinds of warnings about creating empty objects.
For example line 181 in get_messages method. The ```$FindItem``` should get initialized like ```$FindItem = new stdClass();``` and ```$FindItem->ItemShape = new stdClass();``` etc.
I'm a bit new to OO, but I gotta think there is probably a better way to init these objects rather than writing ```$obj = new stdClass()``` all over the place. Maybe some kind of setter?
When I get a little more confident I'll write up a fix and a pull request :-)
Hey, thanks for the great software. Sadly I encountered a problem.
I used the advanced installation and the demo you have on the <>code page.
I filled in the blind-text as my real mailserver (mail.domain.tld), used my outlook/domain login in the code-snippet and executed the code.
This is the error:
➜ Exchange-Web-Services-for-PHP git:(master) ✗ php outlooktest.php
PHP Warning: Creating default object from empty value in /var/www/html/Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 349
PHP Warning: Creating default object from empty value in /var/www/html/Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 355
PHP Warning: Creating default object from empty value in /var/www/html/Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 357
PHP Warning: Creating default object from empty value in /var/www/html/Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 370
All the files are there and are modified as the advanced installation requires.
➜ lib git:(master) ✗ ls
ExchangeClient.php ExchangeNTLMStream.php messages.xsd NTLMSoapClient.php NTLMStream.php Services.wsdl types.xsd
Maybe you can help me with that! Thanks a lot!
When using the get_events() function I get a lot of warnings (while it still seems to work).
Can anybody help?
Thanks!
Warning: Creating default object from empty value in ExchangeClient.php on line 95
Warning: Creating default object from empty value in ExchangeClient.php on line 96
Warning: Creating default object from empty value in ExchangeClient.php on line 97
Warning: Creating default object from empty value in ExchangeClient.php on line 103
Warning: Creating default object from empty value in ExchangeClient.php on line 125
Warning: Creating default object from empty value in ExchangeClient.php on line 126
Warning: Creating default object from empty value in ExchangeClient.php on line 137
Warning: Creating default object from empty value in ExchangeClient.php on line 145
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 137
Warning: Creating default object from empty value in ExchangeClient.php on line 145
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 137
Warning: Creating default object from empty value in ExchangeClient.php on line 145
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
Warning: Creating default object from empty value in ExchangeClient.php on line 156
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.