mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
582 stars 86 forks source link

ErrorNonExistentMailbox Mailbox does not exist #295

Open divansantana opened 1 year ago

divansantana commented 1 year ago

Hi

When using a config with davmail.mode=O365Interactive set, after the oauth login.microsoft.com prompt I get something like this:

DavMail configuration exception: Connect exception:
davmail.exchange.ews.EWSException ErrorNonExistentMailbox Mailbox does
not exist.  request: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><soap:Header><t:RequestServerVersion
Version="Exchange2013_SP1"/></soap:Header><soap:Body><m:GetFolder><m:FolderShape><t:BaseShape>IdOnly</t:BaseShape></m:FolderShape><m:FolderIds><t:DistinguishedFolderId
Id="root"/></m:FolderIds></m:GetFolder></soap:Body></soap:Envelope>

I'm suspecting, it's because the companies exchange/AD is integrated into o365. The calendar and teams for instance is o365 based, as is the oauth integration. However, the actual mailbox, doesn't sit in o365 outlook, only on premise on the exchange server.

I'm suspecting davmail is looking for my mailbox on o365 and saying it's not there.

The URL davmail.url=https://outlook.thecompany.com/owa/ when I open it in a browser, does display the local exchange server's OWA page with the emails. Any idea what else I can do to get this to work?

divansantana commented 1 year ago

Either that, or perhaps it's related to the companies domain name changing.

mguessan commented 1 year ago

Maybe, a quick to check this is to try to access calendar over Caldav, please try:

http://localhost:1080/users/user@company.com/calendar

According to the message above the authentication succeeds, now need to find the right mailbox name

divansantana commented 1 year ago

When I try that, the web page returns Exchange login exception: Not Found and logs say:

2023-10-01 18:51:24,836 INFO  [davmail.caldav.CaldavServer] davmail.connection  - CONNECT - 127.0.0.1:37440
2023-10-01 18:51:27,030 WARN  [CaldavConnection-37440] org.apache.http.client.protocol.ResponseProcessCookies  - Invalid cookie header: "Set-Cookie: AzureAppProxyPreauthSessionCookie_56db8f93-efa4-406f-ab67-0221b97da76e_0feb6734-0a2d-4ac7-8440-311037fd126c_1.4=4|fn0WQpdjiM/ElEHoMp1+/HL35nXcXrqXgT00we5tp++q8EuKbFqt7Yotevl7a07H/9CdWWYxMy5nHcNhqCKJPKWMO4JotgV0upk25ZaZ3EchhqBCcH7+W0nCJ1ZOfU+seFTv1C6DKdNo5nEqALuD6bUY0oTgMtT4TcCJl6MaKdnk9xxphBH8EOZW0dmi6t3dWV53uSduD9gS0v1RyQMs0RC07GhjKU0ryZ+dqDfolr3fnEW8h8ZLxqFwCCe0keOL39Jm2pXoPVjeVN7oQKrnxTs5aMLJEaG2E8mBbSQqcnI=; expires=Sun, 01 Oct 2023 17:01:26 GMT; path=/; Secure; SameSite=None". Invalid 'expires' attribute: Sun, 01 Oct 2023 17:01:26 GMT
2023-10-01 18:51:27,280 WARN  [CaldavConnection-37440] org.apache.http.client.protocol.ResponseProcessCookies  - Invalid cookie header: "Set-Cookie: AzureAppProxyPreauthSessionCookie_56db8f93-efa4-406f-ab67-0221b97da76e_41ee576d-7940-4a99-aaf4-e42c0bc6ec20_1.4=4|ggr40qmafhK5wU36HADY9GegC+CGVpXYzhWObMlYCI4PwkPd3zFEAalZgpipwY516zj+A/v7k28kf3CfqvMkki1aiwAPEc6McLurVbw/3oYUOX3W0F6Z/dfEgRN71lgTXCwDXLUZQZufSpBjmpO/z8eoRX0YDkdqLjrgx0FSAYKUJobxXkqYutMT0c/IuC96xTv18ynGWI7ZL8J7w5UO8EZErC1oAyx9s27zJXhQWCa1icJj9oblki9Y5sbbROSd2POEaS3kdrnBatD/DINhqhQOtr3YwvNRaT0bHsuas4E=; expires=Sun, 01 Oct 2023 17:01:27 GMT; path=/; Secure; SameSite=None". Invalid 'expires' attribute: Sun, 01 Oct 2023 17:01:27 GMT
2023-10-01 18:51:29,152 ERROR [CaldavConnection-37440] davmail.exchange.ExchangeSession  - Exchange login exception: Not Found
2023-10-01 18:51:29,152 ERROR [CaldavConnection-37440] davmail  - Exchange login exception: Not Found
davmail.exception.DavMailException: Exchange login exception: Not Found
        at davmail.exchange.auth.ExchangeFormAuthenticator.authenticate(ExchangeFormAuthenticator.java:239)
        at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:208)
        at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:93)
        at davmail.caldav.CaldavConnection.run(CaldavConnection.java:178)
2023-10-01 18:51:30,172 INFO  [CaldavConnection-37440] davmail.connection  - DISCONNECT - 127.0.0.1:37440