Wednesday, 31 October 2012

Changing the cPanel "Configure Email Client" server addresses in WHM 11.34

One of the great things about cPanel is how easy it makes it for non-technical people to use, for instance within Email Accounts, clicking More and then Configure Email Client provides you with links to automatically configure several email clients, or the details required to do it manually. The data is automatically generated to show the relevant domain's POP3/IMAP/SMTP server details (specific to each domain), but what if you prefer to have a single set of service addresses, how do you update this page to show your preferred details.

In the previous version it was quite simple, you simply edited the clientconfinclude.html that's found within /usr/local/cpanel/base/frontend/x3/mail/ and replaced the dynamic code with your static text.

With WHM 11.34 that's changed, and the .html file no longer controls any of the data, instead it calls the template file clientconfinclude.tmpl which then generates all of the content. Simply doing the switch like before isn't as simple any more, especially if you're not much of a coder, but it's still doable with some minor modifications. Unfortunately the code seems to use multiple methods to call the server addresses, so you have to do different mods for different sections of code.

First all we have the SSL hosts, which is easily the simplest part. Line 11 to line 24 deals with getting those details, with the next section storing them for use later. Without deleting anything simply insert these three new lines immediately before line 26 that begins "SET ssl_hosts = {" :

SET imap_ssl_host = 'imap.mydomain.com';
SET pop3_ssl_host = 'pop3.mydomain.com';
SET smtp_ssl_host = 'smtp.mydomain.com';

That will then force all SSL references to use your information. Now look for the line :

SET non_ssl_mail_server = webmail_settings.domain;

Copy it, and edit the entries so you have :

SET non_ssl_mail_server = 'pop3.mydomain.com';
SET non_ssl_mail_server_smtp = 'smtp.mydomain.com';

In the manual settings section, if you'd prefer the default POP3/IMAP to be IMAP then change pop3 to imap above. Now look for the line :

[% locale.maketext("Outgoing Server:") %]

at around line 685. On the next line, change "non_ssl_mail_server" to be "non_ssl_mail_server_smtp" (so it matches the name used in the last step).

If you save this file and reload the page you should now find most of the links / text now points to your preferred addresses. Unfortunately it's not perfect, there are a few entries that display incorrectly, and I haven't yet worked out where they get their information or how to change it, but hopefully it will be a bit of help for someone.