Applicable to:
- Plesk for Linux
Question
By default, Plesk stores all mailboxes in the /var/qmail/mailnames/
directory. How to change this location?
Answer
PLESK_WARN: Changing the Maildir location for Plesk Premium Email is currently not supported. Such a possibility will be added in the future.
-
Find what SMTP and IMAP/POP3 servers are in use: Login 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
and change thePLESK_MAILNAMES_D
variable: specify a new location for mailbox directory so that it is like:Note: It is not possible to use capital letters in the name of the directory that will be used for the 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.
# grep PLESK_MAILNAMES_D /etc/psa/psa.conf
PLESK_MAILNAMES_D <new_mailnames_directory> -
Move mailboxes from the current directory to the new location with the command:
# cp -ap /var/qmail/mailnames/* /new/mailnames/directory/
-
For 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 the dovecot service and pc-remote service:
# service dovecot restart
# service pc-remote restartFor 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 settings:
# service postfix start
# plesk repair mail -y -
Set the new home directory for the popuser. In
/etc/passwd
file change/var/qmail/
to the required one:
For Red Hat based OS:
From:CONFIG_TEXT: popuser:x:30:31:POP3 service user:/var/qmail/popuser:/sbin/nologin
To:
CONFIG_TEXT: popuser:x:30:31:POP3 service user:/<new_mailnames_directory>/popuser:/sbin/nologin
For Debian based OS:
From:CONFIG_TEXT: popuser:x:30:31:POP3 service user:/var/qmail/popuser:/bin/false
To:
CONFIG_TEXT: popuser:x:30:31:POP3 service user:/<new_mailnames_directory>/popuser:/bin/false
Note: Before creating new mailboxes on new domains it may be required to configure SELinux in the following way:
# chcon -R -t mail_spool_t <new_mailnames_directory>
Comments
36 comments
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!
@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)
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.
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
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.
@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.
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.
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.
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
@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-
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
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?
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.
What is missing in this instruction set is an update of the apparmor configuration?!
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??
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
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 .
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
@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.
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.
@Daniele Vasalli
Hello!
The backup manager will use the new mailboxes path. It was checked on a test server.
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!
Hi,
After moving the mailboxes path, does the backup consider the new path?
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.
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.
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.
Hi New Look Media - our recommendation is to rename mount folder to lower case.
@Mohamed Elkaffas
In order to contact us check the following article
Hello Dennis Rahmen
I would say it depends on the quality (speed/bandwidth) of connections to the network share, first of all.
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
------------------
Please sign in to leave a comment.