jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

Get different "To" Email Adresses #599

Open diggde opened 3 years ago

diggde commented 3 years ago

Version (e.g. 1.0, dev-master): 1.0 PHP version: 7.2

Description of problem: I get different "To" email adresses when using Php-Ews compared to outlook header info. How can I get the same "To" email adress like in the outlook header? Hint: daten@domain.com is a public folder, everthus@domain.com is an email-alias to this public folder. But I need the real "To" email adress, not the name of the public folder. How can I get this email adress?

Example Header from Outlook (To = everthus@domain.com):

X-NetatworkMailGateway-Sender: 20210514080003706ba4b967794e69be4426f6dde0p0na@domain.com
From: Update <update@domain.com>
To: everthus@domain.com
Message-ID: <0100017969e3bc08-ea9f0a43-53da-4e00-9f00-a28ecf02bb03-000000@domain.com>
Subject: Email Assistance
MIME-Version: 1.0
Content-Type: multipart/alternative; 
    boundary="----=_Part_31921436_177684020.1620979203073"
Bounces-to: 20210514080003706ba4b967794e69be4426f6dde0p0na@domain.com
Date: Fri, 14 May 2021 08:00:03 +0000
Feedback-ID: 1.us-east-1.ZHcGJK6s+x+i9lRHKog4RW3tECwWIf1xzTYCZyUaiec=:UpdateSES
Return-Path: 20210514080003706ba4b967794e69be4426f6dde0p0na@domain.com
X-MS-Exchange-Organization-Network-Message-Id: 2f51a1ed-f61f-48bb-d4a4-08d916ae551c
X-MS-Exchange-Organization-AuthSource: EXCHS1.domain.local
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 10
X-MS-Exchange-Organization-AVStamp-Enterprise: 1.0
X-MS-Exchange-Transport-EndToEndLatency: 00:00:00.3350204
X-MS-Exchange-Processed-By-BccFoldering: 15.02.0858.012

Code request:

$request = new GetItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
$request->ItemShape->BodyType = BodyTypeResponseType::BEST;

Response from Php-Ews (To = daten@domain.com):

  ["ToRecipients"] => object(jamesiarmes\PhpEws\ArrayType\ArrayOfRecipientsType)#14653 (1) {
    ["Mailbox"] => array(1) {
      [0] => object(jamesiarmes\PhpEws\Type\EmailAddressType)#14654 (5) {
        ["EmailAddress"] => string(17) "daten@domain.com"
        ["ItemId"] => NULL
        ["MailboxType"] => string(12) "PublicFolder"
        ["Name"] => string(5) "daten"
        ["RoutingType"] => string(4) "SMTP"
      }
    }
  }

Thanks for help!