ecederstrand / exchangelib

Python client for Microsoft Exchange Web Services (EWS)
BSD 2-Clause "Simplified" License
1.18k stars 248 forks source link

Send_and_Save() not working for the mailboxes created using powershell-exchange online package #968

Closed PrajjawalBanati closed 3 years ago

PrajjawalBanati commented 3 years ago

Describe the bug I tried to create mailboxes using Powershell exchange online module and the mailboxes were showing in the exchange admin center. Then I created a message object for each email I did use a new message object (by running them in a for loop). It's actually showing one Exception that is:- ErrorNonExistentMailbox('The SMTP address has no mailbox associated with it.') If I am able to login to the mailbox using outlook then how come it is showing that the following SMTP address has no mailbox associated. With older versions, we never received such errors.

To Reproduce Try to create an online exchange mailbox using powershell. Then run send_and_save() function for the same.

Expected behavior It should send a mail to the mailbox

Log output

Exception in send_email_online_mailbox(): No valid version headers found in response (ErrorNonExistentMailbox('The SMTP address has no mailbox associated with it.'))
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\version.py", line 229, in guess
    list(ResolveNames(protocol=protocol).call(unresolved_entries=[name]))
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\resolve_names.py", line 52, in _elems_to_objs
    for elem in elems:
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 210, in _chunked_get_elements
    yield from self._get_elements(payload=payload_func(chunk, **kwargs))
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 228, in _get_elements
    yield from self._response_generator(payload=payload)
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 194, in _response_generator
    response = self._get_response_xml(payload=payload)
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 321, in _get_response_xml
    return self._get_soap_messages(body=body, **parse_opts)
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 418, in _get_soap_messages
    self._raise_soap_errors(fault=fault)  # Will throw SOAPError or custom EWS error
  File "C:\Program Files\Python38\lib\site-packages\exchangelib\services\common.py", line 455, in _raise_soap_errors
    raise vars(errors)[code](msg)
exchangelib.errors.ErrorNonExistentMailbox: The SMTP address has no mailbox associated with it.

Additional context Python using 3.8 Exchangelib using 4.5.0

ecederstrand commented 3 years ago

The only error message we get from the server is ErrorNonExistentMailbox but that doesn't give any hints as to why. I think this question is better answered by your Exchange admins. They should be able to help you find out what is wrong on the server side.

PrajjawalBanati commented 3 years ago

I am using Office 365 exchange online. It's a SAAS product. For on-prem environments, we use Powershell only but for office 365 we use this library. It used to work before.

ecederstrand commented 3 years ago

Then the question is what changed since the last time it worked? If you try to use the same version of exchangelib that you used the last time it worked, then you can find out whether the problem is with exchangelib or the Exchange server.

ecederstrand commented 3 years ago

I assume this is a problem that needs to be fixed o the server. Feel free to reopen if you think anything can be improved in exchangelib.