jamesiarmes/php-ews

Sending email using an Exchange account without associated mailbox

gtorassa opened this issue · 0 comments

Version (e.g. 1.0, dev-master): 1.0.0-beta.2
PHP version: 5,5,9
Microsoft Exchange version: 2010

Description of problem:
I'm trying to send an email connecting to an Exchange server but I get a Not Existing Mailbox error.
To connect to the Exchange server I'm using an account that doesn't have a default mailbox associated to it.
On that server a mailbox is configured to be accessible from my account.

E.g.

Exchange account used for authentication (domain/user): test/bob
Mailbox configured on the server: alice@sample.com, bob doesn't have any default mailbox associated to it
bob is allowed to access alice@sample.com mailbox

How can I send emails from alice@sample.com using my account (bob) without getting a Non Existing Mailbox error?

Example request:

        $client = new Client($host, $username, $password, $version);
	
	// Build the request
	
	$request = new CreateItemType();
	$request->Items = new NonEmptyArrayOfAllItemsType();
	
	// Save the message, but do not send it.
	
	$request->MessageDisposition = MessageDispositionType::SAVE_ONLY;
	
	// Create the message.
	
	$message = new MessageType();
	$message->Subject = $subject;
	$message->ToRecipients = new ArrayOfRecipientsType();
	
	// Set the sender.
	
	$message->From = new SingleRecipientType();
	$message->From->Mailbox = new EmailAddressType();
	$message->From->Mailbox->Name = "Alice";
	$message->From->Mailbox->EmailAddress = "alice@sample.com";
	
	// Set the recipient.
	
        $recipient = new EmailAddressType();
	$recipient->Name = 'name';
	$recipient->EmailAddress = 'address';
	$message->ToRecipients->Mailbox[0] = $recipient;
	
	// Set the message body.

	$message->Body = new BodyType();
	$message->Body->BodyType = BodyTypeType::HTML;
	$message->Body->_ = $body;
	
	// Add the message to the request.
	
	$request->Items->Message[] = $message;
	$response = $client->CreateItem($request);

Example response:

Message failed to create with ErrorNonExistentMailbox

Additional details: