Percio Castelo.
PT Home
When IMAP directories disappear: a hands-on Roundcube and Dovecot troubleshooting report
← Back to blog

When IMAP directories disappear: a hands-on Roundcube and Dovecot troubleshooting report

6/7/2026 · 4 min · Email · 839 views

Recently, I stumbled upon one of those problems that make any infrastructure analyst scratch their head. The scenario was as follows: email directories physically existed on the server, with recent modification timestamps, but simply did not appear for the user within the Roundcube Webmail interface.

If you work with mail server administration, you know that the /home/user/mail/domain.com directory is the heart of the delivery process. I could list the directories via terminal, via SSH, and they were there: .Folder A, .Folder B, .Archive. So why did Roundcube insist on showing only the Inbox?

Below is the complete operational and forensic guide I followed to debug and solve this failure in Dovecot and Roundcube.


1. Physical anatomy of maildir#

By default, Dovecot stores emails in the Maildir format. Each subfolder created by the user is physically represented on the disk as a hidden directory starting with a dot (.).

The correct structure of a healthy mailbox follows this hierarchy:

/home/user/mail/domain.com.br/user/
├── cur/                    # Processed (read) messages
├── new/                    # New messages pending read status
├── tmp/                    # Temporary files in transit from the MDA
├── .Drafts/                # Drafts folder
│   ├── cur/
│   ├── new/
│   └── tmp/
├── .Sent/                  # Sent Items folder
│   ├── cur/
│   ├── new/
│   └── tmp/
├── .Trash/                 # Trash folder
│   ├── cur/
│   ├── new/
│   └── tmp/
├── .Custom Folder/         # Hidden subfolder directory
│   ├── cur/
│   ├── new/
│   └── tmp/
├── subscriptions           # Plain text file listing active (subscribed) folders
├── dovecot.index           # Main message index for the Inbox
├── dovecot.index.cache     # Fast-search cache files
└── dovecot.index.log       # Indexing transaction history log

If the physical folders exist on the disk, but the cur, new, and tmp subfolders do not exist inside them, Dovecot will ignore the directory as a valid mailbox.


2. Permissions and Dovecot user context diagnostics#

The Dovecot daemon must read email directories under the permissions of the OS user associated with the hosting account (rather than the global root or dovecot user).

Identify which user executes delivery processes:#

ps aux | grep dovecot | head -3

Audit maildir owner and permissions:#

In integrated control panels like cPanel or DirectAdmin, the directory owner must be the account user (user) and the corresponding group (user or mail).

# Verify current permissions
ls -la /home/user/mail/domain.com.br/mail/

# Dovecot needs read access. If permissions are incorrect:
sudo -u dovecot ls -la /home/user/mail/domain.com.br/mail/

Permissions correction:#

# 1. Adjust the owner and group recursively
chown -R user:group /home/user/mail/domain.com.br/mail

# 2. Ensure read and execute permissions on directories (750 or 755)
find /home/user/mail/domain.com.br/mail -type d -exec chmod 750 {} +

# 3. Ensure read and write permissions on message files (640 or 644)
find /home/user/mail/domain.com.br/mail -type f -exec chmod 640 {} +

3. Disk space and quota verification#

When an account reaches its maximum disk quota or inode limit (either OS filesystem limits or panel limits), Dovecot is prevented from updating or creating temporary control files, resulting in folders disappearing from the client.

Check filesystem quotas:#

# OS user quota
sudo repquota -a | grep user

# Physical consumption of the mail directory
du -sh /home/user/mail/

Check quotas via Dovecot:#

# List quotas for all mailboxes
doveadm quota get -A

# Get quota for a specific user
doveadm quota get -u [email protected]

4. Preventive backup and reindexing of corrupted indexes#

Dovecot index files (dovecot.index*) act as a cache to improve performance. If the server experiences sudden power failures, quota exhaustion, or I/O hangs, these indexes can become corrupted.

Safe reindexing procedure:#

# 1. Create a backup directory with a timestamp
BACKUP_DIR="/root/dovecot-index-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"

# 2. Copy the indexes preventively keeping the path structure
find /home/user/mail/domain.com.br -name "dovecot.index*" -exec cp --parents {} "$BACKUP_DIR/" \;

# 3. Delete the corrupted indexes from the production directory
find /home/user/mail/domain.com.br -name "dovecot.index*" -delete

On the user's next connection, Dovecot will read the messages from the disk and recreate the indexes cleanly from scratch.


5. The subscriptions file and modified utf-7 encoding#

The IMAP protocol requires the client to know which folders to display through the subscriptions file located in the root of the Maildir. If the folder exists on the disk but is not listed in this file, it will not be displayed in Roundcube.

Verify the subscriptions file:#

# Locate the subscriptions file
cat /home/user/mail/domain.com.br/mail/subscriptions

Modified utf-7 for special characters:#

IMAP uses a variant of UTF-7. Folder names with accents are not written in plaintext. For example, a folder named "Promoções" must appear in the file as: Promo&AOcA9Q-es

If the physical name on the disk is .Promoções but in the file it appears as Promoções plain, there will be a mismatch and the folder will disappear.

# Inspect subscriptions file encoding looking for invalid characters
hexdump -C /home/user/mail/domain.com.br/mail/subscriptions

Manually correcting the file:#

If the file is blank or corrupted, reconstruct it by scanning for hidden folders on the disk:

# List physical directories and generate the base subscriptions list
echo -e "INBOX\nDrafts\nSent\nTrash" > /home/user/mail/domain.com.br/mail/subscriptions

You can also manage subscriptions securely using the Dovecot CLI:

# Subscribe a specific folder for the user
doveadm mailbox subscribe -u [email protected] "Promo&AOcA9Q-es"

6. Direct IMAP connection tests via CLI#

To isolate whether the failure lies in Roundcube or the Dovecot server itself, perform direct queries via the terminal.

Test IMAP connection via openssl (port 993/ssl):#

openssl s_client -connect localhost:993 -quiet

After establishing the handshake, type the protocol commands:

a1 LOGIN [email protected] "user_password"
a2 LIST "" "*"
a3 SELECT INBOX
a4 LOGOUT

Analyze if the LIST command returns all folders.

Test connection with cURL and lftp:#

# List mailboxes via curl (bypass certificate validation)
curl -k "imaps://localhost" -u "[email protected]:password" --list-only

# Connect and list folders using lftp
lftp -u "[email protected],password" -e "set ssl:verify-certificate no; ls; bye" localhost

7. Roundcube configuration and logs#

If doveadm and OpenSSL show the folders correctly but Roundcube still omits them, the error lies within the PHP interface.

Locate and audit Roundcube configurations:#

# Locate the configuration file
find /var/www -name "config.inc.php" 2>/dev/null

# Check IMAP variables
grep -i "imap" /var/www/roundcube/config/config.inc.php

Ensure that the $config['default_host'] or $config['imap_host'] variable points to the correct address and that there are no folder filtering restrictions.

Monitor server logs:#

Monitor Dovecot logs and Roundcube error logs simultaneously during login attempts:

# Dovecot Logs
tail -f /var/log/maillog | grep -i dovecot
# Or via journalctl
journalctl -u dovecot -f

# Roundcube Error Logs
tail -f /var/log/roundcube/errors.log

# Check general status and active Dovecot configurations
systemctl status dovecot
doveconf -n | head -20

8. Post-fix verification#

After performing permissions adjustments and index cleanup, verify the success of the procedure:

# 1. Verify if new index files were generated
ls -la /home/user/mail/domain.com.br/mail/.*/dovecot.index*

# 2. Run directory listing via doveadm
doveadm mailbox list -u [email protected]

# 3. Validate folder status (shows message counts and size)
doveadm mailbox status -u [email protected] "ALL"

Checklist: IMAP folders do not appear in Roundcube#

Use this structured checklist to triage and resolve the incident:

1. Physical layer and permissions#

  • [ ] Do physical folders exist with the leading dot prefix on disk? (e.g. /home/user/mail/domain.com.br/mail/.Folder)
  • [ ] Does the internal structure (cur, new, tmp) exist in each subfolder?
  • [ ] Is ownership of the files correct (owned by the account user, not root)?
  • [ ] Are permissions set to 750 for directories and 640 for files?

2. Indexes and subscriptions#

  • [ ] Was a backup of the index files created before deleting the old ones?
  • [ ] Were the corrupted dovecot.index* files removed?
  • [ ] Does the subscriptions file exist and list all required subfolders?
  • [ ] Is the encoding in the subscriptions file in the Modified UTF-7 format?

3. Services and quotas#

  • [ ] Is the account or VPS disk quota within limits?
  • [ ] Is Dovecot running and logging activity without errors in /var/log/maillog?
  • [ ] Does the local connection test via OpenSSL (port 993) list all directories successfully?
  • [ ] Was /var/log/roundcube/errors.log analyzed looking for backend connection failures?

Was this article helpful?

Leave a quick reaction to help prioritize future technical guides:

839 reads
Creative Commons Attribution-NonCommercial

This post is licensed under CC BY-NC.

Comments

Join the discussion below.

0 comments