|
If you are like me and prefer your clients to use their own webmail tied to their domain instead of yours then you would be a little dissapointed that ISPConfig 3 doesn't allow for adding {DOMAIN} to the Server Config webmail link url. This useful change allows you to connect to the webmail server of the user. The reason I have this configured is that not all my webmails for each domain resides on the same host and can be on a number of other hosting boxes based on where the http://webmail.{domain} points to, so I can't direct it to 1 global webmail site. There's a very small simple hack that can give you that functionality as long as you remember to use the DNS template to always add a CNAME or A record for "webmail" otherwise the url redirect fails as the DNS doesn't resolve. By going into System->Interface Config ->Mail, you can use the steps below to allow you to redirect the webmail in ispconfig to http://webmail.{DOMAIN} which will be the domain of the mailbox you are selecting. Instruction Steps1. Edit the file /usr/local/ispconfig/interface/web/admin/form/system_config.tform.php 1.a Search down for the word "webmail_url_error_regex" and you will find the regex pattern above it as below shows. /usr/local/ispconfig/interface/web/admin/form/system_config.tform.php
'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
1.b Add a curly braces into it as below and save/exit the file. /usr/local/ispconfig/interface/web/admin/form/system_config.tform.php
'regex' => '/^[{}0-9a-zA-Z\:\/\-\.]{0,255}$/',
2. Now edit the file /usr/local/ispconfig/interface/web/mail/webmailer.php 2.a Search for the below lines /usr/local/ispconfig/interface/web/mail/webmailer.php
/* Get the data to connect to the database */ $dbData = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = " . $emailId); 2.b Change the SELECT query to also extract "email" along with the "server_id" as below /usr/local/ispconfig/interface/web/mail/webmailer.php
/* * Get the data to connect to the database */ $dbData = $app->db->queryOneRecord("SELECT server_id,email FROM mail_user WHERE mailuser_id = " . $emailId);
3. Now search further below for the if statement checking for webmail_url as below line shows /usr/local/ispconfig/interface/web/mail/webmailer.php
if($global_config['webmail_url'] != '') { header('Location:' .$global_config['webmail_url']); } else { 3.a Add the following line just after the IF statement and change the header variable seen as below. /usr/local/ispconfig/interface/web/mail/webmailer.php
if($global_config['webmail_url'] != '') { $webmail_dom=split("@",$dbData['email']); $webmail_dom=$webmail_dom[1]; $webmail_server=str_replace("{DOMAIN}",$webmail_dom,$global_config['webmail_url']); header('Location:' . $webmail_server); } else {
4. Log into ISPConfig3 and go into Email and Email Mailboxes. For any email address you select the "webmail" button on the right no matter what domain, it will replace the {DOMAIN} for the email domain of the user and browse to that webmail site. So if the user is This e-mail address is being protected from spambots. You need JavaScript enabled to view it , the webmail button will take you to webmail.usersdomain.com Hope this works well for you, please contact me if you have any issues. If you feel this was helpful to you and would like to donate $5 or any figure you feel, please help my research/work by donating below. |
ISPConfig3 - Webmail.domain.tld redirect change on email section




