[Bug] Messages from shared mailbox being copied into the logged in user.
(Cross-posting to issue tracker).
I'm trying to sync my emails with Davmail and isync, and I'm encountering a strange issue, where emails from my shared mailboxes, which my main account has delegated access to, are copied to the logged in account's mailbox. I'm on Exchange 365.
It's very strange.
I have attached the davmail.properties. I'm on the latest release, on
NixOS, but I've tried it in Docker too. I've also attached the relevant
sections (main account and shared mailbox, redacted) of mbsyncrc.
I was just wondering what I should do? Is there a setting I should use? davmail.properties.txt mbsyncrc-davmail-sample.txt
Have you access to OWA and tried "send as shared account". It could be a setting on the exchange server, in which send folder "send as"-mails are stored.
@ifrh I'm not sure what you mean, but in M365 admin, I have it set to Full Access. This isn't happening upon sending emails, but when doing an initial sync over IMAP.
IMAP sync moves mails from one inbox to an inbox of an other account? => Client filter rules envolved?
or some strange filesystem config:
- symliked or hardlinked boxes
@ifrh No filter rules. No symlinks.
Essentially, when using shared mailboxes, the contents of a delegated mailbox are copied to the logged-in user. It is only done in that one direction, not bidirectionally.
I did try using offlineimap, but I had the same issue, and isync was more reliable in terms of sync, minus the mail leakage.
I have attached the .mbsyncrc to this comment for reference. It's been sanitised slightly, and the 'Far' host is non-existent currently.
cc: @mguessan - did you need any further details on this? Hoping to move over to Davmail soon, rather than using Exchange's buggy IMAP implementation - feel free to ping me on Libera (shymega[i]) if you want to discuss in more depth; or here.
In order to understand this issue we would need a log of the actual actions sent over IMAP, related to current folder selections and MOVE commands
@mguessan If I did do that, I would have to email it to you directly - I do not feel comfortable uploading logs of my folders on my email mailboxes to GitHub. Is that OK?
@shymega wrote:
@mguessan If I did do that, I would have to email it to you directly - I do not feel comfortable uploading logs of my folders on my email mailboxes to GitHub. Is that OK?
@mguessan suggests doing exactly that in the DavMail FAQ at https://davmail.sourceforge.net/faq.html, so I'm sure it's OK with him. Just be sure to include a link to this GitHub issue in your email so that he knows what it's for. :smile:
Does anyone have example .mbsyncrc configs I could try? I've isolated this happening when shared mailboxes with different domains to the logged-in user happening - but only one shared mailbox thus far.
I sent logs to @mguessan via email.
I've attempted to reproduce with OfflineIMAP and isync again, but with tweaks in the shared mailbox username syntax. No luck. I'm reluctant to use OfflineIMAP, given it's not maintained.
I can sync my OSS mailbox first, then use Thunderbird to access my main mailbox, and see emails from the former appear in that mailbox. So it may not be specific to the OSS mailbox, but it sure is reproducible. That was via isync.
Is it possible this is leakage from Dovecot locally? I could try syncing directly to a Maildir...
Tried syncing directly to a Maildir, same reproducible issue. Standard config from the Arch Wiki.
I suspect this is an issue with Davmail, as I got a message when syncing with IMAP:
IMAP warning: ignoring mailbox '/users/[email protected]/' due to empty name component
The DOMAIN.org.uk is redacted to prevent me getting spam, but I got this after isync connected to the shared mailbox over IMAP. Maybe this is related...
Interesting, I suspect the root cause of this issue is somewhere we don't take context into account when searching.
Accessing a shared mailbox is based on syntax at: https://help.ubuntu.com/community/ThunderbirdExchange
Split logic is in ImapConnection.splitUserName, then buildFolderContext that will check baseMailboxPath to apply the right search context.
However this context does not seem to applied consistently.
Are you guys trying to sync from en Exchange mailbox or to an Exchange mailbox?
From an Exchange Online mailbox (EWS) to a local Dovecot IMAP mailbox. Bidirectional.
I do wonder if my sync tool is syncing emails from the local Dovecot IMAP mailbox to the Exchange logged-in user, not the other way round. That would make sense.
@mguessan From that Ubuntu link, it doesn't seem to give examples for Exchange Online.
I could try syncing the shared mailbox, but with isync configured to pull emails, not push, and see if that works?
Quick update on this: I identified and fixed an issue in IMAP implementation. The folder context when specified as part of the username was not taken into account for some of the IMAP verbs.
This should now be fixed in trunk, builds are available on github home page.
@mguessan Nice work! I've tested it, and it seems to work with isync, but with Neomutt, I get an error with StringIO.decode.
I think that's due to Mutt doing something funny with the shared mailbox username though.
@shymega wrote:
I think that's due to Mutt doing something funny with the shared mailbox username though.
Can you capture a WIRE debug log, extract just the relevant lines from it, and post those lines here? That would help track it down, I think.
@esabol I'll make a note to open a new issue.
The fix works, but EWS is throttling my emails, even with a size limit, via M365.
I think I'll go back to use Microsoft's IMAP for now, and revisit once Davmail has Graph API support - would be happy to test for @mguessan.
Closing for now as resolved.