Using Office 365 mail in a corporate setting with Okta authentication. The authentication seems to be fine but for the past two days there have been some messages that give errors and prevents 'fetchmail' from pulling messages from DavMail after it. As far as I'm aware I haven't been delegated any mailboxes although Office365 Outlook does show some Microsoft Teams groups that I belong to and may be considered delegates for group messages, although I don't see any recent ones there that would explain this. Additionally, the message count implies it is something in my main mailbox. It started without having my updated Davmail in over a month but using latest out of Git repo doesn't change anything.
2020-08-09 13:18:12,921 DEBUG [ImapConnection-34052] davmail.exchange.FolderLoadThread - Still loading INBOX (1474 messages)
2020-08-09 13:18:12,921 DEBUG [ImapConnection-34052] davmail - > 1474 EXISTS
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > * 191 RECENT
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > * OK [UIDVALIDITY 1]
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > * OK [UIDNEXT 11898899]
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > * FLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded Junk)
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded Junk *)]
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - > A0003 OK [READ-WRITE] SELECT completed
2020-08-09 13:18:12,922 DEBUG [ImapConnection-34052] davmail - < A0004 EXPUNGE
2020-08-09 13:18:13,000 DEBUG [ImapConnection-34052] davmail.exchange.ExchangeSession - Delete 11898544
2020-08-09 13:18:13,077 DEBUG [ImapConnection-34052] davmail.exchange.ews.EWSMethod - ErrorInternalServerError
2020-08-09 13:18:13,077 ERROR [ImapConnection-34052] davmail - ErrorInternalServerError An internal server error occurred. The operation failed. Name: InnerErrorMessageTextA delegate session is not allowed in arbitration mailbox for delegate access., Name: InnerErrorResponseCodeErrorDelegateSessionNotAllowedWithinASession, Name: InnerErrorDescriptiveLinkKey0
request: <soap:envelope xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><soap:header><t:requestserverversion version="Exchange2013_SP1"></t:requestserverversion></soap:header><soap:body><m:deleteitem affectedtaskoccurrences="AllOccurrences" deletetype="HardDelete" sendmeetingcancellations="SendToNone"><m:itemids><t:itemid changekey="CQAAABYAAADD9kOMOkZ3T5NMdR+fScYfAAY+y6XB" id="AAMkAGIwZjVjZjZkLTNkYjctNDZmNi1hZDkzLTBjMzUxMWZlZWIxZQBGAAAAAAD4p26/UDVWQYQ1HJqu59kVBwCzX+a5xIUwS6mipHHDfUZJAAAAweibAADD9kOMOkZ3T5NMdR+fScYfAAY7zC3wAAA="></t:itemid></m:itemids></m:deleteitem></soap:body></soap:envelope>
davmail.exchange.ews.EWSException: ErrorInternalServerError An internal server error occurred. The operation failed. Name: InnerErrorMessageTextA delegate session is not allowed in arbitration mailbox for delegate access., Name: InnerErrorResponseCodeErrorDelegateSessionNotAllowedWithinASession, Name: InnerErrorDescriptiveLinkKey0
request: <soap:envelope xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><soap:header><t:requestserverversion version="Exchange2013_SP1"></t:requestserverversion></soap:header><soap:body><m:deleteitem affectedtaskoccurrences="AllOccurrences" deletetype="HardDelete" sendmeetingcancellations="SendToNone"><m:itemids><t:itemid changekey="CQAAABYAAADD9kOMOkZ3T5NMdR+fScYfAAY+y6XB" id="AAMkAGIwZjVjZjZkLTNkYjctNDZmNi1hZDkzLTBjMzUxMWZlZWIxZQBGAAAAAAD4p26/UDVWQYQ1HJqu59kVBwCzX+a5xIUwS6mipHHDfUZJAAAAweibAADD9kOMOkZ3T5NMdR+fScYfAAY7zC3wAAA="></t:itemid></m:itemids></m:deleteitem></soap:body></soap:envelope>
at davmail.exchange.ews.EWSMethod.checkSuccess(EWSMethod.java:778)
at davmail.exchange.ews.EwsExchangeSession.internalExecuteMethod(EwsExchangeSession.java:2997)
at davmail.exchange.ews.EwsExchangeSession.executeMethod(EwsExchangeSession.java:2960)
at davmail.exchange.ews.EwsExchangeSession.deleteMessage(EwsExchangeSession.java:502)
at davmail.exchange.ExchangeSession$Message.delete(ExchangeSession.java:1618)
at davmail.imap.ImapConnection.expunge(ImapConnection.java:1595)
at davmail.imap.ImapConnection.run(ImapConnection.java:277)
2020-08-09 13:18:13,077 DEBUG [ImapConnection-34052] davmail - > A0004 BAD unable to handle request: ErrorInternalServerError An internal server error occurred. The operation failed. Name: InnerErrorMessageTextA delegate session is not allowed in arbitration mailbox for delegate access., Name: InnerErrorResponseCodeErrorDelegateSessionNotAllowedWithinASession, Name: InnerErrorDescriptiveLinkKey0 request: <soap:envelope xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><soap:header><t:requestserverversion version="Exchange2013_SP1"></t:requestserverversion></soap:header><soap:body><m:deleteitem affectedtaskoccurrences="AllOccurrences" deletetype="HardDelete" sendmeetingcancellations="SendToNone"><m:itemids><t:itemid changekey="CQAAABYAAADD9kOMOkZ3T5NMdR+fScYfAAY+y6XB" id="AAMkAGIwZjVjZjZkLTNkYjctNDZmNi1hZDkzLTBjMzUxMWZlZWIxZQBGAAAAAAD4p26/UDVWQYQ1HJqu59kVBwCzX+a5xIUwS6mipHHDfUZJAAAAweibAADD9kOMOkZ3T5NMdR+fScYfAAY7zC3wAAA="></t:itemid></m:itemids></m:deleteitem></soap:body></soap:envelope>
2020-08-09 13:18:13,077 INFO [ImapConnection-34052] davmail.connection - DISCONNECT - 0:0:0:0:0:0:0:1:34052
This happened again and my mailbox got up to 100,000+ messages (lots of automated emails), because "fetchmail" issues an EXPUNGE as its first action and that was failing so it never made progress. I patched DavMail to always report success for EXPUNGE and now "fetchmail" can retrieve the messages again. I see the message counter going down in realtime on the webmail Outlook 365 so probably the EXPUNGE isn't that necessary anyway.
Note sure why fetchmail issues an EXPUNGE command.
It probably marked some messages deleted before.
=> won't work if you don't have write access on the mailbox.
Can you configure Fetchmail to always leave messages on the server and thus not try to delete them ?
The funny thing is I'm only trying to pull messages from my Outlook 365 main inbox, so I should have full permissions to the mailbox. I think what happens is some Outlook calendar invite emails are treated specially, because it has only happened around meeting invite or cancel messages. Could be related to the four corporate "Groups" I have listed at the bottom left of the Outlook web interface, although the meeting invite/cancels I have in mind as possibly triggering it would (I would guess) be from individuals, not those groups.
Fetchmail is issuing the EXPUNGE because it sees a message previously-flagged as deleted. That can be adjusted somewhat with a configuration setting but it only delays when the error happens. I don't have enough of a mailbox quota to keep all of the messages I receive on the server for very long.
My workaround is working for now, I just wish I could better narrow it down to that delegate access error, or know specifically what message did it. (As far as I know nobody has ever delegated any mailbox access to me nor do I delegate to others.)