Skip to content

Folder Name Case Sensitivity #803

Description

@thomas-mullaly

Describe the bug
I'm running into problems with the way MailKit and some IMAP servers (Office 365 in my case) handle casing of folder names. Specifically, it seems MailKit is case-sensitive when LISTing a folder on the IMAP server (via ImapClient.GetFolder(string)), but the IMAP server is not.

To Reproduce
If I have folder called "SWEET" (exact casing) and I call ImapClient.GetFolder("sweet") the IMAP server will acknowledge the folder exists during the LIST command, but will respond with the folder names correct casing ("SWEET"). MailKit correctly parses the results (and caches the ImapFolder), but in ImapEngine.GetFolder(List, string) it iterates through the list of folders that got returned, but does an exact case match to find the one you were trying to load. When it can't find it (because the casing is different) it throws the FolderNotFoundException. I've got some protocol logging output from an Office 365 account which I hope helps explain the situation better:

C: A00000007 LIST "" sweet
S: * LIST (\HasNoChildren) "/" SWEET
S: A00000007 OK LIST completed.

Expected behavior
I would expect MailKit to not throw the FolderNotFoundException since the IMAP server acknowledged that folder actually exists.

Desktop (please complete the following information):

  • OS: Windows 10, .NET Framework 4.7.2

Additional context
I'm working on switching an existing application (at my job) over to MailKit from a 3rd party mail library that has caused a lot of problems in the past. The 3rd party library we were using appears to have just papered over the casing problem and correctly returned the right folder. Additionally, the folder names we look for are controlled by customers, so it's not as easy as just "use the right folder name casing" to load the folder.

I'm not sure what the IMAP RFC spec says about folder name case sensitivity, but it appears that Office 365 is somewhat lenient on that front.

I looked around to see if any similar issues had already been posted here, but I didn't see any. My apologies if this behavior has already been reported elsewhere.

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

    bugSomething isn't workingcompatibilityCompatibility with existing softwareenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions