Applicable to:
- Plesk for Linux
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
"<?php echo $VAR->includeTemplate('domain/PCI_compliance.php') ?>"
(there are two of them):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.
CONFIG_TEXT: <?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
Comments
3 comments
Hi,
I can't open the / usr / local / psa folder
because it is a link to
/ Opt / psa
where I find the webmail.php file
adding lines, can I make them in this file?
Thanks
Hello Ben Essere,
You should create the custom directory first:
mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail
Then copy the original content and edit:
I was searching exactly for this but it seems not to work on my end. Also it seems not to be possible regardless of what you try. Instead you have to create your domain in plesk first and then install an own Webmail of your choice in the documentroot. Only then you have the opportunity to offer only one central entrypoint for your friends and/or customers by telling them, please go to this URL yadayada.....
Negative side effect is that you have to maintain your custom webmail installation at your own risk to stay up to date and secure.
The other scenario not to create the domain in Plesk but still apply the changes to the webmail.php file also does nothing at all. So whatever you do seems to be a dead end.
Please sign in to leave a comment.