Email Accounts Not Created After Upgrade

Hi,

After upgrading CyberPanel from the earlier version to the latest, I am facing a serious issue with email account creation and restore during migration.

  • When importing a cPanel full backup with the script:
    /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/cPanelImporter.py --path /home/backup/
  • Email accounts are NOT created for the imported domains.
  • The actual mailbox folders under /home/vmail/<domain>/<user>/Maildir/ are not being created automatically, even after the email account appears in CyberPanel.
  • This worked correctly in the past (same migration script, earlier CyberPanel versions), but fails after the upgrade.
  • Manually created mailboxes (via CyberPanel > Email > Create Email) also do NOT create the corresponding directories in /home/vmail/ for new accounts, so login and mail delivery both fail.
  • Only workaround is to create the required folders manually and fix permissions, which is not practical for larger migrations.

Details:

  • Maildir structure in /home/vmail is used, with the expected path from Dovecot config:
    mail_location = maildir:/home/vmail/%d/%n/Maildir
  • Ownership/permissions of /home/vmail/ are correct (vmail:vmail).
  • Dovecot and Postfix services are running without fatal errors, but no maildir is created for new or imported users.
  • Old domains/accounts (from before upgrade) work fine, only new ones have this issue.

Troubleshooting already attempted:

  • Restarting Dovecot and Postfix.
  • Re-creating accounts in CyberPanel.
  • Manually triggering logins via Webmail (does not trigger maildir creation).
  • Manually creating /home/vmail/<domain>/<user>/Maildir/cur new tmp folders, which then allows the account to work.
  • Checked logs (/var/log/maillog and /var/log/dovecot.log) — no clear fatal errors, but maildir creation simply does not happen.
  • Verified mail_location in doveconf -n output is correct.

This was NOT a problem before the upgrade!

Expected Behavior:

  • Creating an email account in CyberPanel should automatically create the appropriate maildir folder structure in /home/vmail/.
  • cPanelImporter.py should also restore email accounts with their maildir structure, as in previous versions.

Actual Behavior:

  • Email accounts does not appear in CyberPanel UI, and their folders are missing in /home/vmail/.
    New Email accounts for domains appear in CyberPanel UI, but their folders are missing in /home/vmail/.
  • As a result, webmail and IMAP/SMTP login do not work until maildir is manually created.

Steps to Reproduce:

  1. Upgrade CyberPanel to latest version.
  2. Import a cPanel backup or create a new email account.
  3. Check /home/vmail/<domain>/ for new user directories (they are missing).

Environment:

  • OS: AlmaLinux 9
  • CyberPanel version 2.4 Build 2

Request:

Please investigate and fix this regression or provide a workaround/patch so email account creation also creates the correct maildir folders after upgrade.
Let me know if you need more logs or details!

Thanks!

Thank you for reporting this issue. I’ve investigated the problem with email accounts not being created after upgrading to v2.4.2. The issue is related to maildir folders not being automatically created for new email accounts.

Root Cause

The email account creation function in CyberPanel was not creating the physical maildir directories required by Dovecot, and the Dovecot configuration was missing the auto-creation settings.

Immediate Workaround

You can manually create the missing maildir folders:

For a specific email account (replace domain.com and username with actual values)

mkdir -p /home/vmail/domain.com/username/Maildir/{cur,new,tmp}
mkdir -p /home/vmail/domain.com/username/Maildir/.{Archive,Drafts,Sent,“Junk E-mail”,“Deleted Items”}/{cur,new,tmp}
chown -R vmail:vmail /home/vmail/domain.com/username
chmod -R 700 /home/vmail/domain.com/username

Permanent Fix (Apply these changes):

  1. Update Dovecot Configuration to enable auto-creation:

Edit /etc/dovecot/dovecot.conf and add to protocol lda section:

protocol lda {
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
# … existing settings …
}

Then restart dovecot

systemctl restart dovecot

  1. Update CyberPanel’s email creation code:
    The maildir creation code was commented out in /usr/local/CyberCP/plogical/mailUtilities.py. We’ve fixed this in the v2.4.2 branch.

For Bulk Import Issues

If you’re importing from cPanel and multiple accounts are affected:

Script to fix all missing maildirs

  for domain in /home/vmail/*; do
      if [ -d "$domain" ]; then
          for user in $domain/*; do
              if [ -d "$user" ] && [ ! -d "$user/Maildir" ]; then
                  username=$(basename "$user")
                  domainname=$(basename "$domain")
                  echo "Creating maildir for $username@$domainname"
                  mkdir -p "$user/Maildir/{cur,new,tmp}"
                  mkdir -p "$user/Maildir/.{Archive,Drafts,Sent,Junk E-mail,Deleted Items}/{cur,new,tmp}"
                  chown -R vmail:vmail "$user"
                  chmod -R 700 "$user"
              fi
          done
      fi
  done

This issue has been fixed in our v2.4.2 branch. The fix includes:

  • Proper maildir creation during email account setup
  • Dovecot configuration updates to enable auto-creation
  • Improved error handling for email operations

Thank you for your patience, and please let us know if you encounter any other issues!

Thank you for your great support! I upgrade again to latest v2.4.2 branch, see the files, and indeed everything is ok now.

I request you to open a seprate thread for that.

1 Like