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 and add:UTF-8
to the end of the second parameter:# 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:UTF-8 -
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
38 comments
Following the above guide, I was left unable to log into the mailboxes (even using webmail). So I reverted back to the original dovecot and postfix configurations, and re-run the mchk utility - and access was returned. Have I missed something?
Furthermore - one of your collegues recently posted a warning that the "mchk" command is not advised, and that instead admins should instead, be using "plesk repair mail" ...which is the better advice?
https://talk.plesk.com/threads/all-mail-passwords-are-gone-after-mchk.346354/#post-840746
@Stuart Mayne hi, I checked the solution described in the article step by step and it works as expected. Have you run mchk utility as it is suggested on the step 8?
Regarding question about 'plesk repair mail' utility, such tool extends the functionality of mchk. It runs mchk tool along with the other repair actions, that is why it was recommended to use. Note that I have updated the article and replaced mchk with plesk repair mail.
Very weird error the creating email after migrate folder if path contains uppercase.
"unable to change to mbox folder /media/2tb/mailnames/"
"Fatal error: plesk::mail::FSError(unable to remove quota: Success: "/media/2TB/mailnames/"
I've solved it creating a symlink from "2tb" to "2TB". I think could be a bug.
I've checked twice misspelling on both files.
PS: Also step 9 is not needed en Ubuntu.
@Emilio Ortiz Could you please provide the following:
I'm not migrating platform. I'm only changing the path of the mail folder to a bigger one.
Plesk Migrator is not installed.
Regards!
@Emilio Ortiz
Hello!
The issue was not reproduced in the test environment with the same OS and Plesk version.
Consider contacting Plesk Technical Support.
Hi,
After moving the mailboxes path, does the backup consider the new path?
@Daniele Vasalli
Hello!
The backup manager will use the new mailboxes path. It was checked on a test server.
Hi,
thank you,
if i have a firewall who checks UDP/ TCP Ports IN/ OUT which Ports do i have to allow in Ordner to have everything working normal?
@Lenor, hello, please check the following https://support.plesk.com/hc/en-us/articles/213932745-Which-Ports-Need-To-Be-Opened-for-all-Plesk-Services-to-Work-with-a-Firewall-
Hi, is there no way, to make this changes permanent?
We lost this today, again.
EDIT:
Well i createt a File: /etc/dovecot/conf.d/custom.conf and this works perfectly.
Just enter all things from dovecot.conf which you want to change, and done.
Or do i miss somthing? This works great. And this would keep Changes on Update, right? So maybe you can adjust Article.
After update the path in "/etc/dovecot/dovecot.conf" changed back to default causing Mailbox unavailability. It would be great if updates wouldn't interfere with this configuration. This could be a feature inside Plesk instead of manipulating configuration files that can be overwritten. Or even alert us before updates that can potentially break this configuration.
Any improvement to this is welcomed.
Thanks
Hello @Lenor and @Filipe,
Step 6 of the article was adjusted, now changes won't be reset after upgrades.
Creating configuration in /etc/dovecot/conf.d/ allows to avoid this.
Hello every1, thanks for this extremly usefull and clear guide. My disk is full so I need to move all my mails to the brand new partition, permanently mounted on "/mnt/sdb/" using "ext4" as the primary one "/sda/sda1".
I found a difference with in my installation on step 2, I got this:
$features['SMTP_Server'] = "Postfix";
$features['IMAP_POP3_Server'] = "Courier-IMAP";
$features['SMTP_Server_package'] = "postfix";
$features['IMAP_POP3_Server_package'] = "courier-imap";
So, what do I have to change in place of your "dovecot" configurations in steps 6 and 7.
Im using Plesk v12.0.18_build1200140606.15 os_CentOS 6 on CentOS 6.9 (Final).
Thanks,
German
@German A
Thank you for the question. When Courier is used, there is no need to change anything on step 6. On step 7, restart all Courier services (courier-authdaemon, courier-imapd, courier-imaps, courier-pop3d and courier-pop3s)
Thanks for your previous answer, now there is an error on step 8 when executing "plesk repair mail"
[root@ /]# plesk repair mail
PHP Notice: Undefined index: mail in /usr/sbin/plesk on line 57
Usage: plesk [command]
Commands:
help - Show help and exit
version - Show product version information
db - Database related commands. Open MySQL console by default.
bin - Run the specified Plesk command-line utility (e.g., domain, client)
sbin - Run the specified Plesk internal utility
php - Run a PHP script using the proper PHP interpreter
conf - Open the specified Plesk configuration file in the editor
log - Display the specified Plesk log file
installer - Parallels Installer shortcuts and command completion.
I hope this doesn't interrupt my service since is an enterprise solution for many clients. Thanks in advance for you kind help.
************UPDATE************
There is an unedited line in "/etc/psa/psa.conf" that has this information:
# Qmail directory
QMAIL_ROOT_D /var/qmail
This shouldn't be updated as well?, BTW I did and still not working.
Should I use any of this utils instead?
[root@ /]# /usr/local/psa/admin/bin/mailmng
mailmng mailmng-core mailmng-imap mailmng-outgoing mailmng-service
mailmng-black-white mailmng-domain mailmng-mailname mailmng-server mailmng-transport
***********LAST UPDATE************
I sucessfully runned this command "/usr/local/psa/bootstrapper/pp12.0.18-bootstrapper/bootstrapper.sh repair" but I don't know if this is the substitute of "plesk repair mail".
So I'll wait untill your reply. Thanks and sorry about this trouble.
Also, the next step 9, "chcon -R -t mail_spool_t /mnt/sdb/qmail/mailnames/" throw me thousands of errors like this:
.....
chcon: can't apply partial context to unlabeled file `new'
chcon: can't apply partial context to unlabeled file `tmp'
chcon: can't apply partial context to unlabeled file `cur'
chcon: can't apply partial context to unlabeled file `new'
chcon: can't apply partial context to unlabeled file `tmp'
chcon: can't apply partial context to unlabeled file `.Spam'
chcon: can't apply partial context to unlabeled file `Maildir'
chcon: can't apply partial context to unlabeled file `@attachments'
chcon: can't apply partial context to unlabeled file `.qmail'
....
So I guess the previous command was necessary or there is also something else wrong. I hope you can help me and advise others like me. This is a brand new installation without any modification of the OVH VPS with the native Plesk installation.
Thanks for reading and your kind help.
Finally I think there is another problem in step 10, since you never ask or guide to "cp" or migrate the "popuser" directory but you request to change it in "/etc/passwd", please clarify if you can.
Thanks!
Hello @German A,
>chcon: can't apply partial context to unlabeled file
The 9 step is applied if Selinux is used, otherwise this step can be skipped.
You can check Selinux status using the command below:
-----------
getenforce
-----------
--------------------------------------
As for the following message:
>plesk repair mail
>PHP Notice: Undefined index: mail in /usr/sbin/plesk on line 57
>Usage: plesk [command]
"plesk repair mail" command was introduced in Plesk 12.5, as I can see your Plesk version is 12.0.
Note that Plesk version 12.X has reached End of Life starting from 1.01.2019.
End-of-Life means that the product will cease to receive further development and technical support requests will no longer be accepted https://www.plesk.com/support/plesk-lifecycle/
It is strongly recommended to upgrade Plesk to the supported version.
--------------------------------------
>Finally I think there is another problem in step 10, since you never ask or guide to "cp" or migrate the "popuser" directory but you request to change it in "/etc/passwd", please clarify if you can.
popuser is a specific user, which own all mailboxes in Plesk., since the mail home directory was changed, it is required to make the corresponding changes in "/etc/passwd".
--------------------------------------
>There is an unedited line in "/etc/psa/psa.conf" that has this information:
># Qmail directory
>QMAIL_ROOT_D /var/qmail
>This shouldn't be updated as well?, BTW I did and still not working.
There is no need to edit this line in "/etc/psa/psa.conf", only PLESK_MAILNAMES_D should be edited.
Thanks for your complete and kind replies.
As Plesk version 12.X has reached End of Life I understand that I can't get a support for that problem, BUT then I would just like to know if this missing step will affect the migration, since I need to finish this task.
Thanks again and have a nice week.
What is missing in this instruction set is an update of the apparmor configuration?!
Hello @b_p,
Firstly, please note that Plesk Onyx supports AppArmor on Ubuntu 16.04 only since Ubuntu 14.04 reached End-Of-Life https://www.plesk.com/lifecycle-policy/
As for your question, check where the old directory is specified in AppArmor.
For example,
-------------
# grep -r "mailnames" /etc/apparmor.d/*
/etc/apparmor.d/local/usr.lib.dovecot.pop3:/var/qmail/mailnames/** rwk,
/etc/apparmor.d/local/usr.lib.dovecot.dovecot-lda:/var/qmail/mailnames/** rwkl,
/etc/apparmor.d/local/usr.lib.dovecot.imap:/var/qmail/mailnames/** rwk,
-------------
Then, re-apply AppArmor policy and reset AppArmor cache:
------------------
apparmor_parser -r -T -W <path-to-file>
service apparmor recache
------------------
Is it not possible to just move /var/qmail to another location, and then symlink to it? ln -s /path/to/new/location /var/qmail
Regards,
Tom
@Tom
The symlink method is not the best option, because unpredictable errors may appear. It was not tested, so it is recommended to use the method described in the article.
Hi There,
I have recently changed my mailnames folder location from /var/qmail/mailnames to /email_1/qmail/mailnames (separate drive) using this (very good) guide. All went well, despite I think the last step should read: popuser:x:30:31:POP3 service user:/<new_popuser_directory>/qmail/popuser:/sbin/nologin
In my case I copied original /var/qmail/popuser to /email_1/qmail/popuser so I changed popuser on /etc/passwd to: popuser:x:30:31:POP3 service user:/email_1/qmail/popuser:/sbin/nologin
However I still needed to create symlinks from /var/qmail/mailnames -> /email_1/qmail/mailnames and /var/qmail/popuser -> /email_1/qmail/popuser, because after the switch (to the new drive) I tried to install Kolab Premium Email extension which resulted in an error because mailnames folder wasn't where it should be (/var/qmail/mailnames). Only after creating the symlinks I could install Kolab Premium Email successfully.
My question is: is there a conf file on Kolab I should edit too (pointing to mailnames location) or it's best to leave the symlinks (just in case)?
Regards,
Pedro Pereira
Hello Pedro,
It is good to hear that you resolved (worked around) the issue with Kolab installation on your own.
I performed some tests to reproduce the mentioned behavior, however, the only condition, when Kolab fails to install, is renamed/removed original /var/qmail/ directory.
To change the default location of mailboxes it is needed to copy the content from /var/qmail/mailnames, however, the directory /var/qmail/ itself should remain untouched.
If you face with the issue further, for example for another sever, we would like to investigate this behavior, for that please submit a request here https://support.plesk.com/hc/en-us/requests/new
Hi There,
To be more specific I copied /var/qmail/mailnames -> /email_1/qmail/mailnames (another drive) and
/var/qmail/popuser -> /email_1/qmail/popuser
/var/qmail was not moved, only removed the two above folder (mailnames and popuser) to the new drive
When trying to install Kolab it failed with (taken from Panel log):
"[2019-09-02 05:11:32.242] ERR [panel] Error: Execution failed: mkdir: cannot create directory '/var/qmail/mailnames/.spamtrain': No such file or directory
[2019-09-02 19:42:38.780] ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/filemng' 'root' 'cp' '-r' '/usr/local/psa/var/modules/kolab//dovecot-sieve/sa-learn-spam.sh' '/var/qmail/popuser/sa-learn-spam.sh' '--allow-root'] with exit code [1]
[2019-09-02 19:42:38.803] ERR [1] '/usr/local/psa/admin/bin/filemng' 'root' 'cp' '-r' '/usr/local/psa/var/modules/kolab//dovecot-sieve/sa-learn-spam.sh' '/var/qmail/popuser/sa-learn-spam.sh' '--allow-root' failed with code 1.
stdout:
cp: cannot create regular file ‘/var/qmail/popuser/sa-learn-spam.sh’: No such file or directory
filemng: Error occurred during /bin/cp command.
stderr:
filemng: Error occurred during /bin/cp command.
[2019-09-02 19:42:38.828] ERR [panel] Task failed: id=1404, pid=28761, type=ext-kolab-task_install, error=filemng failed: filemng: Error occurred during /bin/cp command."
So I created symbolic links between /var/qmail/mailnames -> /email_1/qmail/mailnames and
/var/qmail/popuser -> /email_1/qmail/popuser
and this time it worked. Kolab installed successfully.
Two issues though: 1 - Folders inside the Inbox were moved to out of the Inbox, which resulted in Emails clients to redownload emails (very anoying specially with 1.15Tb of emails)
2 - a new process beam.smp appeared using lots of CPU and Memory (don't know why). Sometimes I have to kill it manually so that it frees CPU and Memory, but it comes back almost immediately. I presume that it is used by Kolab. It seems that the more Emails clients download messages (reindexing because of folders from in to out of the Inbox) the more beam.smp uses resources. Yesterday CPU usage was around 800% and memory usage above 16Gb - brutal and I had to kill the process, before the server stalled (Server with 2 Xeons and 32Gb RAM).
Best Regards
Hello Pedro,
Thank you for the update.
As stated in the article, the only directory to be operated on is /var/qmail/mailnames. All other directories should remain untouched.
Regarding "beam.smp" process. Your assumption is correct - this process used by Kolab. If you still experiencing issues with high CPU/RAM usage with it - submit a ticket to Plesk Support - that we will be able to investigate the issue further https://support.plesk.com/hc/en-us/requests/new .
i have same problem with this beam.smp and tried to request a new support but the license issued outside plesk , and issuer dont know the problem
@Mohamed Elkaffas
In order to contact us check the following article
Please sign in to leave a comment.