Skip to content

Emails from different IMAP folders overwrite each other when "Read all folders" is on #1943

Open

Description

@ichavchavadze

Description

With "Read all folders" (readAllFolders) turned on for an account, mail is received from every IMAP folder of the account, but an email is identified only by the account and the message UID. An IMAP UID is unique only within one folder (RFC 3501, 2.3.1.1), and every folder numbers its messages from 1, so messages in different folders routinely have the same UID. Two such messages become one email:

  • A message is never imported. A new message in INBOX whose UID is already used by a message from another folder (Spam, Sent, …) is treated as already downloaded and skipped.
  • Two messages merge into one email. When both messages are received at once, the email gets some fields of one message and some of the other: for example, the sender and the subject of one and the date and the body of the other.
  • An email moves between folders. When the messages are received at different times, the second one overwrites the folder and the other fields of the first.
  • Folders merge. A folder is identified by its short name within the account, so two subfolders with the same name under different parents become one folder.

Steps to reproduce (Gmail, where every new label numbers its messages from 1; receiving all folders of a Gmail account needs the fix of #1942):

  1. Create two labels and put one message under the first and two other messages under the second.
  2. Turn on "Read all folders" for the account and receive mail.
  3. The message of the first label is missing, and one email of the second label has the sender and the subject of one message and the date and the body of another.

Affects 6.3 and 7.0.

Reason

With "Read all folders" on, the mailbox of an account is incomplete, and some of its emails are mixed from several messages or change folders, without any error. The default mode reads only INBOX and its subfolders, so it is affected only when INBOX has subfolders.

Fix

  • A received email is identified by its folder and its UID, so messages with the same UID in different folders are received as different emails, and none of them is skipped.
  • A received folder is identified by its path, so subfolders with the same name under different parents stay separate.
  • Folders and emails received before the upgrade get the new identifiers when the server starts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions