“User’s Directory Already Exists” Error When Creating an Email Account

How the Issue Manifests

When creating a new email account in SiteWorx, the action fails with an error stating “User’s directory already exists” in the GUI.

../../_images/troubleshoot-userdir-exists.png

There is also an error like this in ~iworx/var/log/iworx.log:

2021-06-18 16:21:31.00690 [b8lndq-3rtn-33jt-WEB] [INFO]  : vadduser barfed :( : /xhr.php
2021-06-18 16:21:31.00699 [b8lndq-3rtn-33jt-WEB] [INFO]  : Error: User's directory already exists : /xhr.php

Troubleshooting Steps

Incorrect Vpopmail Permissions

The most common cause of this issue is incorrect permissions somewhere under the /var/vpopmail directory, most likely with a script under /var/vpopmail/bin. As it can be tedious to try to locate and resolve each specific permissions issue, it is often easier to simply reinstall vpopmail, as that will regenerate the associated files with the correct permissions.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, run the following to reinstall vpopmail:

    yum reinstall vpopmail
    

Misconfigured Mail Directory

vadduser can fail if items are missing from either the SiteWorx account’s mail directory under /home/{unixuser}/var/{domain.com}/mail or an email account’s directory, located under /home/{unixuser}/var/{domain.com}/mail/{user}/Maildir, replacing {unixuser}, {domain.com}, and {user} with the corresponding informaion.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, navigate to /home/{unixuser}/var/{domain.com}/mail. The following is an example of a directory with the correct files intact, with example email boxes for postmaster and user:

    [root@server ~]# cd /home/domainco/var/domain.com/mail/
    [root@server mail]# ls -la
    total 4
    drwx--s--x  5 vpopmail domainco  95 Nov  1 12:56 .
    drwx--x--x 12 iworx    iworx    174 Nov  1 11:26 ..
    -rw-------  1 vpopmail domainco   0 Nov  1 11:26 .bounceon
    drwxrws---  2 vpopmail iworx      6 Nov  1 11:26 .filterrules
    -rw-------  1 vpopmail domainco  58 Nov  1 11:26 .qmail-default
    drwx------  3 vpopmail domainco  21 Nov  1 11:26 postmaster
    drwx--x--x  3 vpopmail domainco  37 Nov  1 12:56 user
    [root@server mail]#
    
  3. If the default files exist in the mail directory, navigate to /home/{unixuser}/var/{domain.com}/mail/{user}/Maildir for each user, to check the directory structure. The following is an example of a directory with the correct files intact, for the email box user:

    [root@server user]# cd /home/domainco/var/domain.com/mail/user/Maildir/
    [root@server Maildir]# ls -la
    total 16
    drwx------ 7 vpopmail domainco 217 Nov  1 12:56 .
    drwx--x--x 3 vpopmail domainco  37 Nov  1 12:56 ..
    drwx------ 5 vpopmail root     108 Nov  1 12:56 .Learn Ham
    drwx------ 5 vpopmail root     108 Nov  1 12:56 .Learn Spam
    drwx------ 2 vpopmail domainco   6 Nov  1 11:27 cur
    -rw------- 1 vpopmail vchkpw    51 Nov  1 12:56 dovecot-uidlist
    -rw------- 1 vpopmail vchkpw     8 Nov  1 12:56 dovecot-uidvalidity
    -r--r--r-- 1 vpopmail vchkpw     0 Nov  1 12:56 dovecot-uidvalidity.63614fc4
    -rw------- 1 vpopmail vchkpw   236 Nov  1 12:56 dovecot.index.log
    -rw------- 1 vpopmail vchkpw   492 Nov  1 12:56 dovecot.list.index.log
    drwx------ 2 vpopmail domainco   6 Nov  1 11:27 new
    drwx------ 2 vpopmail domainco   6 Nov  1 11:27 tmp
    [root@server Maildir]#
    

Incorrect SiteWorx Permissions

Incorrect permissions for files and directories located under a SiteWorx account’s var directory can can cause vadduser to fail when attempting to create a new email box.

Information on how to run the SiteWorx permissions fix tool can be found here.

Account Over Quota

If a SiteWorx account is over its storage quota, new email boxes cannot be added.

  1. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx)

  2. Navigate to SiteWorx > Accounts

  3. Quota information for each SiteWorx account can be found in the Storage column

    siteworx accounts page

Incorrect or Missing vchkpw or vpopmail User/Group Settings

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, use grep to check the listing for vchkpw in /etc/group. The following is an example of the correct group information:

    [root@server ~]# grep vchkpw /etc/group
    vchkpw:x:104:iworx,iworx-horde
    [root@server ~]#
    
  3. Use grep to check the listing for vpopmail in /etc/passwd. The following is an example of the correct user information:

    [root@server ~]# grep vpopmail /etc/passwd
    vpopmail:x:108:104:interworx-unix-users:/home/vpopmail:/bin/true
    [root@server ~]#