Override default domain settings

This plugin is for version 7 of the product and has not been ported to version 8 yet. We'll eventually be rewriting the existing plugins to v8 platform, please let us know if you require this particular plugin there.
To find out which plugins have already been ported to v8, click here.

This plugin allows for supplying custom settings depending on the domain part of email address user logs in with. For instance, you can set incoming or outgoing mail parameters for specific domains.

Upon downloading and extracting plugin package, rename its main directory from:

plugin-override-default-domain-settings-master

to:

override-default-domain-settings

Then you'll need to deploy the plugin so that its index file is available at the following location:

data/plugins/override-default-domain-settings/index.php

To enable the plugin, add the following to array defined in data/settings/config.php file:

'plugins.override-default-domain-settings' => true, 

By default, plugin contains the following sample code:

$oAccountToCreate->IncomingMailServer = 'imap.'.$sEmailDomain;
$oAccountToCreate->OutgoingMailServer = 'smtp.'.$sEmailDomain;

So when user attempts to log in with user@somedomain.com email supplied, the plugin will set imap.somedomain.com for incoming mail hostname, and smtp.somedomain.com for outgoing one.

Certainly, you can replace that code with anything else according to your requirements. For example, your installation is configured to access mail on your local server, but you'd like to allow users log into their GMail accounts too. For that, replace the sample code with the following one:

if ($sEmailDomain === 'gmail.com') {
    $oAccountToCreate->IncomingMailServer = 'imap.gmail.com';
    $oAccountToCreate->IncomingMailPort = 993;
    $oAccountToCreate->IncomingMailUseSSL = true;
    $oAccountToCreate->OutgoingMailServer = 'smtp.gmail.com';
    $oAccountToCreate->OutgoingMailPort = 465;
    $oAccountToCreate->OutgoingMailUseSSL = true;
}

Note that in current version of the product, enabling SSL explicitly is required, supplying SSL-enabled port number isn't enough.

The plugin only takes effect when account is created on first login, so if the account already exists in WebMail database, no changes will be made to it, you would need to delete the account first for custom changes to apply for it.