Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending email using an Exchange account without associated mailbox #598

Open
gtorassa opened this issue May 14, 2021 · 0 comments
Open

Sending email using an Exchange account without associated mailbox #598

gtorassa opened this issue May 14, 2021 · 0 comments

Comments

@gtorassa
Copy link

gtorassa commented May 14, 2021

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: [email protected], bob doesn't have any default mailbox associated to it
bob is allowed to access [email protected] mailbox

How can I send emails from [email protected] 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 = "[email protected]";
	
	// 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant