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

Accessing shared mailbox - The SMTP address has no mailbox associated with it. #641

Closed
lululukas opened this issue Sep 16, 2019 · 11 comments

Comments

@lululukas
Copy link
Contributor

lululukas commented Sep 16, 2019

I'm having trouble accessing a shared mailbox again. I am getting the error exchangelib.errors.ErrorNonExistentMailbox: The SMTP address has no mailbox associated with it whenever I try to access any property of the shared mailbox account, apart from public_folders_root. I am still able to connect to my own email address without problems.

Log for account.root.tree():

Request data:

<?xml version=\'1.0\' encoding=\'utf-8\'?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <s:Header>
        <t:RequestServerVersion Version="Exchange2010_SP2"/>
        <t:TimeZoneContext>
            <t:TimeZoneDefinition Id="W. Europe Standard Time"/>
        </t:TimeZoneContext>
    </s:Header>
    <s:Body>
        <m:GetFolder>
            <m:FolderShape>
                <t:BaseShape>IdOnly</t:BaseShape>
                <t:AdditionalProperties>
                    <t:FieldURI FieldURI="folder:ChildFolderCount"/>
                    <t:FieldURI FieldURI="folder:EffectiveRights"/>
                    <t:FieldURI FieldURI="folder:FolderClass"/>
                    <t:FieldURI FieldURI="folder:DisplayName"/>
                    <t:FieldURI FieldURI="folder:ParentFolderId"/>
                    <t:FieldURI FieldURI="folder:PermissionSet"/>
                    <t:FieldURI FieldURI="folder:TotalCount"/>
                    <t:FieldURI FieldURI="folder:UnreadCount"/>
                </t:AdditionalProperties>
            </m:FolderShape>
            <m:FolderIds>
                <t:DistinguishedFolderId Id="root">
                    <t:Mailbox>
                        <t:EmailAddress>[email protected]</t:EmailAddress>
                        <t:RoutingType>SMTP</t:RoutingType>
                        <t:MailboxType>Mailbox</t:MailboxType>
                    </t:Mailbox>
                </t:DistinguishedFolderId>
            </m:FolderIds>
        </m:GetFolder>
    </s:Body>
</s:Envelope>

Response data:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="442" MinorBuildNumber="0" Version="Exchange2010_SP2"
            xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
            xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <m:GetFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
                <m:GetFolderResponseMessage ResponseClass="Error">
                    <m:MessageText>The SMTP address has no mailbox associated with it.</m:MessageText>
                    <m:ResponseCode>ErrorNonExistentMailbox</m:ResponseCode>
                    <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                    <m:MessageXml><t:Value Name="SmtpAddress">[email protected]</t:Value></m:MessageXml>
                    <m:Folders/>
                </m:GetFolderResponseMessage>
            </m:ResponseMessages>
        </m:GetFolderResponse>
    </s:Body>
</s:Envelope>

EDIT:

Using my personal account, I can confirm that the shared mailbox is properly resolved:

acc.protocol.resolve_names(['[email protected]'])

Out[13]: [Mailbox(name='My Mailbox Name', email_address='[email protected]', routing_type='SMTP', mailbox_type='Mailbox', item_id=None)]
@ecederstrand
Copy link
Owner

Is it possible that the shared account only has public folders?

@lululukas
Copy link
Contributor Author

Nope, it has many folders that are all not public.

I was able to connect to that same mailbox before and access all of its subfolders. It stopped working after this weekend. I was using the latest release, I have now updated to the latest github version, but still the same issue.

@ecederstrand
Copy link
Owner

Does it still work with the same version that worked for you previously? If so, please compare the XML requests to see where we differ.

@lululukas
Copy link
Contributor Author

No that version also does not work any longer, I updated after I encountered the problem. I am aware this might mean that it's not an issue with the library, but nothing about the Exchange configuration has changed..

@ecederstrand
Copy link
Owner

ecederstrand commented Sep 17, 2019

It could be related to #636. You may be hitting different backend nodes in your Exchange cluster, giving you different results depending on which node you hit.

@lululukas
Copy link
Contributor Author

lululukas commented Sep 17, 2019

Looks possible. After skimming over it quickly, it seems that it's mostly related to public folders though? It seems strange to me that I can even access the public_folders_root, although supposedly there is no mailbox at all at that smtp address?

Maybe it helps, this is the XML request and response sent by account.public_folders_root.tree():

<?xml version=\'1.0\' encoding=\'utf-8\'?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <s:Header>
        <t:RequestServerVersion Version="Exchange2010_SP2"/>
        <t:TimeZoneContext>
            <t:TimeZoneDefinition Id="W. Europe Standard Time"/>
        </t:TimeZoneContext>
    </s:Header>
    <s:Body>
        <m:FindFolder Traversal="Shallow">
            <m:FolderShape>
                <t:BaseShape>IdOnly</t:BaseShape>
                <t:AdditionalProperties>
                    <t:FieldURI FieldURI="folder:ChildFolderCount"/>
                    <t:FieldURI FieldURI="folder:EffectiveRights"/>
                    <t:FieldURI FieldURI="folder:FolderClass"/>
                    <t:FieldURI FieldURI="folder:DisplayName"/>
                    <t:FieldURI FieldURI="folder:ParentFolderId"/>
                    <t:FieldURI FieldURI="folder:TotalCount"/>
                    <t:FieldURI FieldURI="folder:UnreadCount"/>
                </t:AdditionalProperties>
            </m:FolderShape>
            <m:IndexedPageFolderView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning"/>
            <m:ParentFolderIds>
                <t:DistinguishedFolderId Id="publicfoldersroot"/>
            </m:ParentFolderIds>
        </m:FindFolder>
    </s:Body>
</s:Envelope>

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope 
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="442" MinorBuildNumber="0" Version="Exchange2010_SP2" 
            xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" 
            xmlns="http://schemas.microsoft.com/exchange/services/2006/types" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
    </s:Header>
    <s:Body 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <m:FindFolderResponse 
            xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
            xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
                <m:FindFolderResponseMessage ResponseClass="Success">
                    <m:ResponseCode>NoError</m:ResponseCode>
                    <m:RootFolder IndexedPagingOffset="0" TotalItemsInView="0" IncludesLastItemInRange="true">
                        <t:Folders/>
                    </m:RootFolder>
                </m:FindFolderResponseMessage>
            </m:ResponseMessages>
        </m:FindFolderResponse>
    </s:Body>
</s:Envelope>

@lululukas
Copy link
Contributor Author

OK, so the problem was indeed on our side, the shared mailbox was moved to a new "cloud" environment which changed the endpoint I have to use for the configuration. Thanks for the help troubleshooting.

@axk7812
Copy link

axk7812 commented Mar 31, 2020

OK, so the problem was indeed on our side, the shared mailbox was moved to a new "cloud" environment which changed the endpoint I have to use for the configuration. Thanks for the help troubleshooting.

Can you share the new endpoint? I'd like to try to see if this is the same issue I'm having but not sure what endpoint

@ecederstrand
Copy link
Owner

You may be able to use autodiscover to fetch the correct endpoint for your account.

@lululukas
Copy link
Contributor Author

@axk7812 this is my configuration since we moved to Office365:

ews_config = Configuration(
        server="outlook.office365.com",
        credentials=credentials,
        version=Version(build=Build(14, 3, 442, 0)),
)

@ecederstrand
Copy link
Owner

As a side note, the version number in that config is probably wrong (O365 is running some version of Exchange 2016), but we can recover from a wrong version number.

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

3 participants