Community Knowledge Base

SmarterMail for WHMCS

Overall Description

SmarterMail for WHMCS consists of two open-source modules that work together: an addon module and a provisioning (server) module. The provisioning module connects WHMCS to one or more SmarterMail servers and lets you sell email "products" built from SmarterMail features such as user counts, mailbox sizes and disk space. It also gives domain administrators a way to manage users, aliases, mailing lists and more from the WHMCS client area, and to log in to SmarterMail directly.

SmarterTools developed these modules to replace the two earlier SmarterMail modules for WHMCS. Products created with the older modules can't be converted, so you'll need to create new products for the new modules. Customers on older products can coexist with customers on new ones, but we recommend moving everyone to the new products for consistency.

Note: The provisioning module loads shared code from the addon module, so both modules must be installed even if you only use one of them.

Skip to:

Goals

The integration has two goals:

  1. Let businesses build email packages from SmarterMail features, such as individual mailbox size or synchronization with email clients and mobile devices using Exchange ActiveSync (EAS) and MAPI/EWS.
  2. Reduce work for server and domain administrators. Once the modules are installed, WHMCS handles creating, suspending and removing SmarterMail domains, and domain administrators can manage their accounts without contacting you.

The integration provides the following features.

Admin Area Features

  • Create domains
  • Suspend domains (the domain is disabled in SmarterMail)
  • Unsuspend domains
  • Terminate domains (the domain is deleted from SmarterMail)
  • Change packages (upgrades and downgrades update the domain's limits and features in SmarterMail)
  • Add and manage Configurable Options that complement your products
  • Add and manage Custom Fields

Client Area Features (i.e., Domain Administration)

  • Manage users: add, delete, edit settings and change passwords
  • Manage user aliases: add, edit and delete
  • Manage domain aliases (when domain aliases are enabled for the product)
  • Manage mailing lists (when mailing lists are enabled for the product)
  • Assign EAS and MAPI/EWS licenses to users (when those accounts are enabled for the product)
  • Log in to SmarterMail webmail
  • Upgrade or downgrade products and configurable options

Prerequisites

  • An existing installation of WHMCS.
  • A licensed installation of SmarterMail Build 100.0.8580 or later.
  • A SmarterMail system administrator account the module can use to manage domains.
  • Network access from the WHMCS server to the SmarterMail web interface (HTTPS recommended).
Note: Current SmarterMail builds require API sessions that impersonate a domain administrator to identify themselves. Earlier versions of the module don't, and actions fail with "Action Failed Missing Auth". If you see this error, update to the latest version of the modules.

Installing the Modules

The SmarterMail modules install the same way as other WHMCS modules.

  1. Extract the zip file that contains the modules. It contains a modules folder with addons and servers subfolders.
  2. Copy the modules/addons/smartermail2 folder to WHMCS/modules/addons/ on your WHMCS server.
  3. Copy the modules/servers/smartermail2 folder to WHMCS/modules/servers/ on your WHMCS server.

Keep both folder names as smartermail2. WHMCS matches each folder name to the module's function names, so a renamed folder won't load.

Configuring the Addon Module

  1. Log in to the admin area of WHMCS.
  2. Go to System Settings → Addon Modules.
  3. Click "Activate" next to "SmarterMail Module".
  4. Click "Configure" next to "SmarterMail Module" and set the Access Control permissions for the admin roles that should have access.
  5. Save your changes.

The addon module's own settings (Addon ID, Module Logging and Enable SSL) support a legacy workflow that sold SmarterMail as a WHMCS product addon on WHM/cPanel hosting. They aren't used when you provision through the SmarterMail server module, so you can leave them at their defaults.

Next, add your SmarterMail server.

Configuring Your Server(s)

Once the modules are installed, you can add your SmarterMail servers to WHMCS and begin provisioning domains.

Adding a Server

  1. Go to System Settings → Servers.
  2. Click "Add New Server".
  3. Click "Go to Advanced Mode" to see all of the server options.
  4. Fill in the following settings:
    • Name - The friendly name for your SmarterMail server within WHMCS.
    • Hostname - The hostname the module uses to reach SmarterMail's web interface and API (for example, mail.example.com). Enter the hostname only, without http:// or https://.
    • IP Address - The primary IP address for your SmarterMail server. This is for your reference in WHMCS; the module connects using the hostname.
    • Module - Select "SmarterMail" from the dropdown.
    • Username/Password - The username and password of a SmarterMail system administrator. The module uses this account to create and manage domains and to sign in as domain administrators on your customers' behalf.
    • Secure - Check this box so the module connects over HTTPS. Leave it unchecked only if SmarterMail isn't available over HTTPS.
    • Port - Leave this blank to use the standard port (443 for HTTPS, 80 for HTTP). If SmarterMail's web interface runs on a different port, check "Override with Custom Port" and enter it.
  5. Click "Test Connection" if you'd like to confirm WHMCS can reach the server, then save your changes.

Creating a Server Group

This step is optional, but server groups help keep things organized, especially if you have more than one SmarterMail server.

  1. On the Servers page, click "Create New Group".
  2. Enter a group name (for example, Mail Servers).
  3. Choose a Fill Type. This decides which server in the group gets new domains.
  4. In the server list, select your SmarterMail server(s) and click "Add" to move them to the Selected Servers box.
  5. Save your changes.

Configuring Your Product(s)/Service(s)

With the modules installed and your SmarterMail server(s) added, you can create the products customers will purchase.

As with servers, product groups are optional, but they help keep things organized. The steps below create a "SmarterMail" group and then add products to it.

Create a Product Group

  1. Log in to the admin area of WHMCS.
  2. Go to System Settings → Products/Services.
  3. Click "Create a New Group".
  4. Enter a Product Group Name (for example, SmarterMail).
  5. Add any other information you'd like, such as a headline, tagline and features. You can also choose the Order Form Template customers will use to order the product(s).
  6. Save your changes.

Create a Product

  1. Click "Create a New Product".
  2. Select the product type.
  3. For Product Group, select the group you created above.
  4. Enter a Product Name (for example, Basic Email).
  5. For Module, select "SmarterMail".
  6. Click "Continue". The product opens with tabs for Details, Pricing, Module Settings, Custom Fields, Configurable Options and more.
  7. On the Module Settings tab, choose the server group (if you created one) and configure the settings described below.
  8. Save your changes.

Module Settings

The Module Settings tab controls what each customer's SmarterMail domain gets when it's created. This lets you build tiers: a basic plan might offer a handful of users and small mailboxes, while a larger plan adds disk space, mailing lists, EAS and MAPI/EWS accounts, and file storage.

For the numeric limits, 0 means unlimited and, where noted, -1 disables the feature for the domain.

  • Domain Folder Path - The folder on the SmarterMail server where domain data is stored. The domain name is added to the end of this path, so include the trailing slash (for example, C:\SmarterMail\Domains\ on Windows or /var/lib/smartermail/Domains/ on Linux). The default is C:\SmarterMail\Domains\.
  • Outbound IP Address - The IP address the domain uses for outgoing mail. Leave it set to "default" to use the server's default.
  • Users - The number of users the domain can have. 0 = unlimited. The default is 5.
  • Mailbox Size Limit (MB) - The default mailbox size for each user, in MB. 0 = unlimited. The default is 1000.
  • User Aliases - The number of user aliases the domain can have. 0 = unlimited, -1 = disabled.
  • Domain Aliases - The number of domain aliases the domain can have. 0 = unlimited, -1 = disabled. When enabled, domain administrators see Manage Domain Aliases in the client area.
  • EAS Accounts - The number of Exchange ActiveSync accounts the domain can assign. 0 = unlimited, -1 = disabled. Requires SmarterMail Enterprise. When enabled, domain administrators see Manage EAS Licenses in the client area.
  • Mailing Lists - The number of mailing lists the domain can have. 0 = unlimited, -1 = disabled. When enabled, domain administrators see Manage Mailing Lists in the client area.
  • MAPI/EWS Accounts - The number of MAPI/EWS accounts the domain can assign. 0 = unlimited, -1 = disabled. Requires SmarterMail Enterprise. When enabled, domain administrators see Manage MAPI/EWS Licenses in the client area.
  • Domain Disk Space Limit (MB) - The total disk space the domain can use, in MB. 0 = unlimited.
  • Active Directory Integration - Lets the domain authenticate users against Active Directory. Requires SmarterMail Enterprise.
  • Webmail Login Customization - Lets the domain customize the webmail login page.
  • Automated Forwarding - Lets users forward their mail automatically.
  • Chat (XMPP) - Enables chat for the domain. Requires SmarterMail Enterprise.
  • Disposable Address - Lets users create disposable addresses.
  • File Storage - Enables file storage for the domain.
  • Global Address List - Shares a global address list across the domain.
  • Online Meetings - Enables online meetings for the domain. Requires SmarterMail Enterprise.
  • Two-Step Authentication - Choose "Enable" to let users turn on two-step authentication, or "Forced" to require it for every user on the domain.
  • Remove domain data on delete - When the service is terminated, also delete the domain's folder and data from the SmarterMail server. If unchecked, the domain is removed from SmarterMail but its files stay on disk.
  • Allow domain administrators to manage Mailbox Size Limit - Lets domain administrators change the mailbox size for their users. They can't set a mailbox larger than the domain's disk space limit.

When you change a customer's package in WHMCS, the module applies the new product's limits and features to the existing domain. The Domain Folder Path is only used when a domain is created.

Configurable Options

Products set the base limits for a domain, such as the number of users or the size of each mailbox. Some customers need more than their plan includes, or a feature their plan doesn't offer, like syncing a mobile device with EAS.

Configurable options let you sell these as add-ons, each with its own price. Customers can choose them when they order, or you can add them to an existing service later.

Each configurable option and each of its choices uses the format <value> | <friendly text>. For the option itself, the value is one of the internal variable names below. For each choice (sub-option), the value must be a number. The friendly text is what customers see.

For example, to sell additional EAS accounts, create an option named "accounts_eas|EAS Accounts" with these choices:

  • 5|5 EAS Accounts
  • 10|10 EAS Accounts

A positive number is added to the product's base value. With the example above, a product that includes 5 EAS accounts plus the "10|10 EAS Accounts" choice gives the domain 15 EAS accounts. If the product has the feature disabled (-1), the base is treated as 0, so the same choice gives the domain 10.

A negative number replaces the product's base value instead. For example, the choice "-5000|5 GB Mailboxes" for mailbox_size sets each mailbox to 5000 MB no matter what the product specifies.

The following variables are available, with the internal variable name in parentheses:

  • Users (users) - The number of users the domain can have. (E.g., 10|10 Additional Users)
  • Mailbox Size (mailbox_size) - The size of each user's mailbox, in MB. (E.g., 1000|1 GB)
  • Domain Size (domain_size) - The total disk space for the domain, in MB. (E.g., 10000|10 GB)
  • Aliases (aliases) - The number of user aliases. (E.g., 100|100 Aliases)
  • Domain Aliases (domain_aliases) - The number of domain aliases. (E.g., 10|10 Domain Aliases)
  • EAS Accounts (accounts_eas) - The number of EAS accounts. (E.g., 20|20 EAS Accounts)
  • MAPI & EWS Accounts (accounts_mapiews) - The number of MAPI/EWS accounts. (E.g., 20|20 MAPI & EWS Accounts)
  • Exchange Accounts (accounts_exchange) - Adds the same number to both EAS and MAPI/EWS accounts, so you don't have to sell them separately. (E.g., 20|20 Exchange Accounts)

Create a Group

  1. Log in to the admin area of WHMCS.
  2. Go to System Settings → Configurable Options.
  3. Click "Create a New Group".
  4. Enter a Group Name and Description, and select the Assigned Products the options apply to.
  5. Save your changes.

Create Options

  1. Click "Add New Configurable Option".
  2. Enter the Option Name (for example, domain_size|Domain Size) and choose the Option Type. The Dropdown type works well for most options because it lets you offer several tiers, such as increasing amounts of disk space.
  3. Add each choice and its pricing, then save your changes and close the window.
  4. Repeat for any other options. A single group can hold multiple options.
  5. Save your changes on the Configurable Option Groups page.

Custom Fields

Custom fields let customers provide details during checkout that the module uses when it creates the domain. For example, you can ask for the username and password of the domain's primary administrator.

To add custom fields:

  1. Go to System Settings → Products/Services.
  2. Edit the product and open the Custom Fields tab.
  3. Enter the Field Name using the format <variable name>|<friendly text>. For example, sm_username|Username and sm_password|Password.
  4. Set the Field Type to Text Box (or Password for sm_password). You can enter a regular expression in the Validation field to restrict what customers enter.
  5. Check "Show on Order Form" so customers can fill in the field, then save your changes.

The following variables are available:

  • sm_hostname - The hostname for the domain in SmarterMail. If this is blank, the module uses mail.{domain}.
  • sm_username - The username of the domain's primary administrator, which becomes the first part of their email address (username@domain). If this is blank, the module uses the username WHMCS assigns to the service. Reserved names such as CON, PRN, AUX, NUL, COM1 and LPT1 aren't allowed.
  • sm_password - The password for the domain's primary administrator. If this is blank, the module uses the password WHMCS assigns to the service.

Logging and Troubleshooting

When a provisioning action fails (creating, suspending, unsuspending, terminating or changing a package), WHMCS shows the error SmarterMail returned on the service's page in the admin area.

Failed logins, token refreshes and logouts between WHMCS and SmarterMail are written to the WHMCS Module Log. To see these entries, go to System Logs → Module Log and click "Enable Debug Logging". Turn it off again when you're done troubleshooting, since the log grows quickly.

The module also has detailed debug logging that records each API request and response. It's off by default. To turn it on:

  1. Open modules/addons/smartermail2/smartermail2_functions.php.
  2. Find the sm_debuglog function.
  3. Uncomment the line //logActivity($msg, $num); by removing the two slashes.
  4. Save your changes.

You can edit the file while WHMCS is running, so there's no need to restart anything. Entries are saved to the Activity Log, under System Logs in the WHMCS admin area. Because these entries can include request data, comment the line out again once you're finished.