Applicable to:
- Plesk for Linux
Question
By default, Plesk stores all mailboxes in the directory /var/qmail/mailnames/
. How to change this location?
Answer
Warning: 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.
-
Find what SMTP and IMAP/POP3 servers are in use: Log in to Plesk and go to Tools & Settings > Mail Server Settings:
-
Connect to the server using SSH.
-
Stop the SMTP service:
# service postfix stop
-
Open the file
/etc/psa/psa.conf
in a text editor and change the value of the variablePLESK_MAILNAMES_D
: specify a new location for mailbox directory:# grep PLESK_MAILNAMES_D /etc/psa/psa.conf
PLESK_MAILNAMES_D /new_directory/mailnamesNote: Capital letters must not be used in the name of the directory that will be used as the new location for mailboxes.
Note: 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.
-
Copy the current mailboxes directory to the parent directory for the new mailboxes directory:
# cp -ap /var/qmail/mailnames /new_directory
For example, if the mailboxes directory is
/mnt/mailnames
, the command should look like this:# cp -ap /var/qmail/mailnames /mnt
Warning: The directory
/var/qmail/mailnames
should not be removed. Only domains' directories can be removed or moved out from there if necessary. -
Change the configuration of the IMAP/POP3 server:
-
Dovecot:
-
Create a new custom file to add variables in it:
# touch /etc/dovecot/conf.d/99-custom_dir.conf
-
Copy the actual location from the file
/etc/dovecot/dovecot.conf
:# egrep -i mail_home\|mail_location /etc/dovecot/dovecot.conf
mail_home = /var/qmail/mailnames/%Ld/%Ln
mail_location = maildir:/var/qmail/mailnames/%Ld/%Ln/Maildir -
Add those 2 variables in the custom file:
/etc/dovecot/conf.d/99-custom_dir.conf
. Then change them to the custom location:# egrep -i mail_home\|mail_location /etc/dovecot/conf.d/99-custom_dir.conf
mail_home = /new/mailnames/directory/%Ld/%Ln
mail_location = maildir:/new/mailnames/directory/%Ld/%Ln/Maildir -
Restart Dovecot and pc-remote service:
# service dovecot restart
# service pc-remote restart
-
-
Courier-IMAP:
No need to change configuration, just restart all Courier services:# service courier-authdaemon restart
# service courier-imapd restart
# service courier-imaps restart
# service courier-pop3d restart
# service courier-pop3s restart
-
-
After all the steps are done, start SMTP service and reconfigure mail services:
# service postfix start
# plesk repair mail -y -
Set the new home directory for the user
popuser
. In the file/etc/passwd
, change/var/qmail/
to the new location:-
For CentOS/RHEL/CloudLinux/AlmaLinux:
From:
popuser:x:30:31:POP3 service user:/var/qmail/popuser:/sbin/nologin
To:
popuser:x:30:31:POP3 service user:/<new_mailnames_directory>/popuser:/sbin/nologin
-
For Debian/Ubuntu:
From:
popuser:x:30:31:POP3 service user:/var/qmail/popuser:/bin/false
To:
popuser:x:30:31:POP3 service user:/<new_mailnames_directory>/popuser:/bin/false
-
Note: Before creating new mailboxes on new domains on CentOS/RHEL/AlmaLinux, it may be required to configure SELinux in the following way:
# chcon -R -t mail_spool_t <new_mailnames_directory>
Comments
36 comments
Emilio Ortiz I have the exact same errors as you when performing a migration, and believe it is related to the capitalization of letters on my drive.
I also get the following error when trying to access any email accounts within plesk.
mailmng-mailname failed: Unable to open dir /mnt/mailstorage/qmail/mailnames/mydomain.com/jeff/@attachments: No such file or directory System error 2: No such file or directory
The path should be /mnt/MailStorage/ not /mnt/mailstorage/
I have also double-checked psa.conf and it looks like this:
PLESK_MAILNAMES_D /mnt/MailStorage/qmail/mailnames
Anyone have additional advice??
Hi New Look Media - our recommendation is to rename mount folder to lower case.
Gentlemen,
I followed the guide, and everything worked without problems. But then I added a new account, and that account doesn't receive emails at all, while it can send.
Friday I got those two errors
Sep 11 17:30:25 server mailmng[21458]: Unable to get default delivery transport string from /var/qmail/mailnames/.default_delivery
Sep 11 17:30:25 server mailmng[21458]: Unable to add delivery string to '/mnt/mail/qmail/mailnames/example.com/surname.n/.qmail'
but today no errors at all. And trying a "plesk repair mail" (or a reboot) doesn't help.
Thanks.
Hello Paolo Gabrielli
Most probably required entries or the file /var/qmail/mailnames/.default_delivery is missing.
As I can see, the issue is currently investigated in the ticket.
"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"
Is this still the case? Also does it improve anything when I am using EXT4 on SSDs?
Hello Dennis Rahmen
I would say it depends on the quality (speed/bandwidth) of connections to the network share, first of all.
Please sign in to leave a comment.