1

情報

私はこのコードを 1 年ほど実行してきましたが、昨日まではすべて正常に機能していました。以下のエラー メッセージを参照してください。このコードは、受信トレイ内の未読メールの数のみをフェッチします。数が増えると、コードを実行しているクライアントでもサウンドが再生されます。私の Exchange サーバーはExchange Server 2013 CU12を実行していますが、常にExchangeWebServices::VERSION_2010で動作しています (コード bolow を参照)。

エラーメッセージ

致命的なエラー: キャッチされない SoapFault 例外: [クライアント] クラス 'EWS_Exception' が /var/www/html/php-ews/NTLMSoapClient.php:87 に見つかりません スタック トレース: #0 /var/www/html/php-ews/NTLMSoapClient .php(87): NTLMSoapClient::__doRequest() #1 [内部関数]: NTLMSoapClient->__doRequest('https://mail.se...', ' http://schemas ....', 1 , 0) #2 /var/www/html/php-ews/ExchangeWebServices.php(552): SoapClient->__call('FindItem', Array) #3 /var/www/html/php-ews/ExchangeWebServices.php (552): NTLMSoapClient_Exchange->FindItem(Object(EWSType_FindItemType)) #4 /var/www/html/mail.php(104): ExchangeWebServices->FindItem(Object(EWSType_FindItemType)) #5 {main} が /var/ でスローされるwww/html/php-ews/NTLMSoapClient.php 87行目

私のコードは、ここにあるものに基づいています: http://litphp.info/want_to_print_unread_mail_body_and_subject_using_ews_from_exchange_server_in_php

私のコード

function __autoload($class_name)
{
    // Start from the base path and determine the location from the class name,
    $base_path = 'php-ews';
    $include_file = $base_path . '/' . str_replace('_', '/', $class_name) . '.php';

    return (file_exists($include_file) ? require_once $include_file : false);
}

$ews = new ExchangeWebServices("mail.server.path.com", $mailuser, $mailpass, ExchangeWebServices::VERSION_2010);

$request = new EWSType_FindItemType();
$itemProperties = new EWSType_ItemResponseShapeType();
$itemProperties->BaseShape = EWSType_DefaultShapeNamesType::ID_ONLY;
$itemProperties->BodyType = EWSType_BodyTypeResponseType::BEST;
$request->ItemShape = $itemProperties;

$fieldType = new EWSType_PathToUnindexedFieldType();
$fieldType->FieldURI = 'message:IsRead';

$constant = new EWSType_FieldURIOrConstantType();
$constant->Constant = new EWSType_ConstantValueType();
$constant->Constant->Value = "0";

$IsEqTo = new EWSType_IsEqualToType();
$IsEqTo->FieldURIOrConstant = $constant;
$IsEqTo->Path = $fieldType;

$request->Restriction = new EWSType_RestrictionType();
$request->Restriction->IsEqualTo = new EWSType_IsEqualToType();
$request->Restriction->IsEqualTo->FieldURI = $fieldType;
$request->Restriction->IsEqualTo->FieldURIOrConstant = $constant;

$request->IndexedPageItemView = new EWSType_IndexedPageViewType();
$request->IndexedPageItemView->BasePoint = 'Beginning';
$request->IndexedPageItemView->Offset = 0;

$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Mailbox = new StdClass;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = 'emailaddress@test.com';
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;

$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

$result = new EWSType_FindItemResponseMessageType();
$result = $ews->FindItem($request);

if ($result->ResponseMessages->FindItemResponseMessage->ResponseCode == 'NoError' && $result->ResponseMessages->FindItemResponseMessage->ResponseClass == 'Success'){

    // Need this variable to check for the new value.
    $count_new = $result->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView;

    // Play sound if value has increased.
    if($_SESSION['count_previous'] < $count_new) {
        echo '<script type="text/javascript">play_sound();</script>';
    }

    // Saving the value for later usage.
    $count = $result->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView;

    // Saving the current count to a session. Need it to compair with the new value ($count_new).
    $_SESSION['count_previous'] = $count;

    if($count > 0) {
        echo '<script type="text/javascript">document.body.style.backgroundColor = "#fc2828";</script>';
        echo "<h1>" . $count . "</h1><br>";
        echo '<img src="img/mail.png" height="165px">';
    } else {
        echo '<h1 class="paddingH12 test">No mail</h1>';
    }

}

しばらくすると、サーバーが 2013 CU12 であるため、コードが VERSION_2010 のように機能しなくなったのではないかと考えました。次の解決策を試しましたが、うまくいきませんでした: https://github.com/jamesiarmes/php-ews/issues/195

この問題を解決する方法を知っている人はいますか? コードが 1 年ほど機能していたのに、今は機能していないので、少しイライラします。サーバー側では何も変更されていません。

前もって感謝します。

4

1 に答える 1