Subject: Re: bug#54158: 28.0.91; duplicate mail downloads in Gnus (IMAP)

From: Roland Winkler <[email-masked]>
Date: Sat, 12 Mar 2022 23:33:24 -0600

On Thu, Mar 10 2022, Eric Abrahamsen wrote:
>> My understanding is that IMAP servers permit to expunge individual
>> messages while keeping others, though I do not want to use this feature
>> (I want to expunge everything after fetching it).  However, I do not see
>> where mail-source-fetch-imap would implement such fine control.  But my
>> problem of multiple downloads exists only for *some*, but not all
>> messages.  So it seems to me we may be looking at the wrong part of the
>> code altogether.  But that's only a wild guess of someone who does not
>> know much about all of this.
>
> I don't know that much, either. I'll set up a local IMAP account and do
> some testing with this, but it will take me a week or so to get to it.
> Can you tell me what IMAP server you're talking to here?

The IMAP server is Office365 that's accessed via a local davmail (for
Office365 interactive authentication).

I was always surprised that the duplicate emails are "mostly spam".
Previously, I sent you my settting of `mail-sources'.  I changed the
line

  :mailbox ("INBOX" "JUNK EMAIL")

to

  :mailbox ("JUNK EMAIL" "INBOX")

Strange enough, I didn't observe any duplicate message downloads when I
tested this for a few days.

To be more specific: if I understand the office365 spam filter
correctly, it puts messages quite generously into the "JUNK EMAIL"
folder, which is why I prefer to review these messages locally.  But
these messages in "JUNK EMAIL" are tagged as spam more or less
aggressively as spam.  Also, I believe gnus won't tell me whether it
downloaded a message from the INBOX or "JUNK EMAIL" folder.  That's why
I cannot tell with certainty for some of the duplicate downloads from
which folder on the server they originated.  But it seems that all my
duplicate messages are coming from the "JUNK EMAIL" folder on the IMAP
server.

I believe that "INBOX" is really the default folder on an IMAP server
that also appears in some gnus defaults.  Then, adding another folder to
:mailbox may be less common.  So my problems arise only in what may be a
less frequent use case.  Certainly, this becomes yet more obscure if it
matters whether a second folder is listed in :mailbox before or after
the default "INBOX".

All the above is describing symptoms.  The root of the problem remains
unclear to me.

Roland