Question
How to redirect webmail of all domains to a specific webmail URL in Plesk?
Answer
For this solution to work, all domains must use a single webmail client: Roundcube or Horde. To enable only one webmail in Plesk, go to Tools & Settings > Webmail and leave only one webmail client enabled.
-
Connect to a Plesk server via SSH.
-
Create a directory for custom configuration templates:
# mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail
-
Copy the original file webmail.php to the created directory:
# cp /usr/local/psa/admin/conf/templates/default/webmail/webmail.php /usr/local/psa/admin/conf/templates/custom/webmail/webmail.php
-
Open the file /usr/local/psa/admin/conf/templates/custom/webmail/webmail.php in a text editor. In this example, we are using the vi editor:
# vi /usr/local/psa/admin/conf/templates/custom/webmail/webmail.php
-
Add the lines below before the lines
(there are two of them):
"<?php echo $VAR->includeTemplate('domain/PCI_compliance.php')
?>"Note: Replace example.com with a domain name and webmail.example.com with a webmail URL that will be used as an entry point for all users.
<?php
if ($VAR->domain->asciiName !== 'example.com') { echo "Redirect permanent / https://webmail.example.com/"; }
?> -
Save the changes and close the file.
-
Regenerate configuration files for all domains:
Note: During this operation websites will be unavailable for a short period of time. The execution time of this command depends on the number of domains on the server.
# plesk repair web -y