Articles in this section

How to change default location of mailboxes in Plesk for Linux

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

Question

By default, Plesk stores all mailboxes in the directory /var/qmail/mailnames/. How to change this location?

Answer

Limitations:
- Capital letters must not be used in the name of the directory that will be used as the new location for mailboxes.
- To avoid performance degradation, the new location for the mailboxes directory should be located in the local file system - it should not be mounted as a network share, such as NFS.
- The directory /var/qmail/mailnames should not be removed. Only domains' directories can be removed or moved out from there if necessary.
- Changing the mailboxes location on Plesk servers with Plesk Premium Email installed is currently not supported. Such a possibility will be added in the future.

  1. Connect to the server via SSH

  2. Stop the SMTP service:

    # systemctl stop postfix

  3. Update PLESK_MAILNAMES_D value in /etc/psa/psa.conf to the new location (replace <new_directory> with new mailbox location path):

    # sed -i 's|/var/qmail|<new_directory>|g' /etc/psa/psa.conf

  4. Copy the current mailboxes directory to the new mailboxes directory:

    # cp -ap /var/qmail/mailnames <new_directory>

  5. Update the configuration of the IMAP/POP3 server:

    Dovecot
    1. Create a new custom configuration file to set new location variables (replace <new_directory> with new mailbox location path):

      • If Plesk version is 18.0.72 or lower:

        # { grep '^mail_home =' /etc/dovecot/dovecot.conf; grep '^mail_location =' /etc/dovecot/dovecot.conf | sed 's/$/:UTF-8/'; } | sed 's|/var/qmail|<new_directory>|g' > /etc/dovecot/conf.d/99-custom_dir.conf

      • If Plesk version is 18.0.73 or higher:

        # { grep '^mail_home =' /etc/dovecot/dovecot.conf; grep '^mail_path =' /etc/dovecot/dovecot.conf; } | sed -e 's|/var/qmail|<new_directory>|g' -e '/lower/! s/}/ | lower}/g' > /etc/dovecot/conf.d/99-custom_dir.conf

    2. Restart Dovecot and pc-remote services:

      # systemctl restart dovecot pc-remote

    Courier-IMAP

    Restart all Courier services:

    # systemctl restart courier-authdaemon courier-imapd courier-imaps courier-pop3d courier-pop3s

    Note: To check which IMAP/POP3 server is being used:
    1. Log into Plesk
    2. Go to Tools & Settings > Mail Server Settings:

    0.png

  6. Start SMTP service:

    # systemctl start postfix

  7. Reconfigure mail services:

    # plesk repair mail -y

  8. Set the new home directory for the user popuser:

    # usermod -m -d <new_directory>/popuser popuser

  9. If server is using CentOS/RHEL/AlmaLinux, configure SELinux for new location:

    # chcon -R -t mail_spool_t <new_directory>/mailnames

Related Articles

Was this article helpful?

Comments

3 comments
Date Votes
  • ATTENTION: It's necessary to set SELinux to permissive as described here before https://support.plesk.com/hc/en-us/articles/12377675193879-How-to-enable-disable-SELinux-on-a-server

    0
  • Hi, is this also possible on mailbox level? Or only "all or nothing"?
    One Customer has huge Amount of Mails, he wants to mount that on other storage. 

    0
  • Plesk has upgraded dovecot to 2.4 in Plesk 18.0.73. 

    dovecot 2.4 heavily changes config params included mail_location.

    This article must be updated with the following path:

    Instead of mail_location:

    mail_path = /XXX/XXX/qmail/mailnames/%{user | domain}/%{user | username}/Maildir

    Removing also :UTF8 param 

     

    1

Please sign in to leave a comment.