Skip to content

IMAP sync fails because Mail sends invalid STATUS <mailbox> (PERMFLAGS) command #13457

Description

@anthonyg2003

Steps to reproduce

This issue is surfaced with an email account that is hosted on Purelymail (puremail.com):

  1. Configure a Purelymail account in Nextcloud Mail via IMAP (imap.purelymail.com:993, SSL/TLS).
  2. Ensure the account has a Sent folder configured as the default Sent folder.
  3. Let the initial synchronization complete.
  4. Enable per-account Mail debug logging:
php occ mail:account:debug <account-id> --on
  1. Run:
php occ mail:account:sync -vvv <account-id>
  1. Observe the failure while syncing the Sent folder.
  2. Check the IMAP debug log and observe:
C: STATUS Sent (PERMFLAGS)
S: BAD STATUS failed. Illegal arguments.

Expected behavior

Nextcloud Mail should successfully synchronize the Sent folder and determine whether permanent/custom message flags are supported without issuing an unsupported IMAP STATUS data item. The account sync should complete successfully.

Actual behavior

Synchronization aborts while processing the Sent folder with:

OCA\Mail\Exception\ServiceException:
Could not get message flag options from IMAP: IMAP error reported by server.

The IMAP log shows that Nextcloud/Horde issues:

C: STATUS Sent (PERMFLAGS)

and Purelymail responds:

S: BAD STATUS failed. Illegal arguments.

Immediately before this, Purelymail successfully reports:

S: * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen \*)]

Mail app version

5.10.11

Nextcloud version

34.0.2

Mailserver or service

Purelymail (https://purelymail.com/)

Operating system

Ubuntu Linux 26.04

PHP engine version

PHP 8.3

Nextcloud memory caching

memcache.local: \OC\Memcache\APCu; memcache.distributed: not configured

Web server

Apache (supported)

Database

PostgreSQL

Additional info

Purelymail rejects STATUS Sent (PERMFLAGS) with BAD STATUS failed. Illegal arguments. However, it successfully returns PERMANENTFLAGS during SELECT/EXAMINE. RFC 9051 STATUS data items do not include PERMFLAGS and so maybe that's why it doesn't support it?

Nextcloud Mail legitimately needs to determine whether a mailbox supports permanent/custom flags for IMAP-backed tags and message flags. However, Purelymail already supplies this information through the standard PERMANENTFLAGS response to SELECT/EXAMINE. The subsequent Horde-generated STATUS (PERMFLAGS) query appears redundant and causes synchronization to abort on servers that reject that non-standard STATUS item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions