Email Templates

From WHMCS Documentation

The email templates allow you to customise the messages that go out to your customers when actions occur inside WHMCS. You can customize every email that goes out to a customer here.

To edit an email template, go to Setup > Email Templates and click the edit icon next to the template you want to change.

You can also toggle plain text and HTML email sending on a per-email basis from the editor page.

You can't modify the sender and subject of the email support ticket email templates. This is because they need to be in a specific format in order for the email piping feature to import email replies into the ticket system.

Creating Custom Templates

You can create your own email templates to serve as custom welcome emails for products or messages you send manually but frequently.

To do this:

  1. Use the Create New Email Template area at the top of the page.
    • You can only create email templates for the types you can manually send: General, Product, Domain and Invoice.
    • Use a unique name for the template so you can identify it in the send message menus. Only admin users will see the name you give it.
  2. The system will display an editor interface. Compose the email subject and message.

The email should now appear in the appropriate place. For more information, see the Messages/Emails page.

WHMCS reserves the email template name "Mass Mail Template" when sending a mass mail. The system will remove any email template you create with this name after you send a mass mail. We recommend that you don't use this name.

Adding an Attachment

An email template can contain attachments that the system includes each time you send that particular email to clients. Navigate to Configuration () > System Settings > Email Templates and click Edit next to the appropriate email template.

Then, on your computer, browse to the file that you want to attach. Click Add More if you wish to attach more than one file. When you click Save Changes, the system will upload the files to your downloads directory.

Adding Headers and Footers

It's possible to configure a universal header and footer to use in all email templates. The header will display at the top of every email template that the system sends. The footer will display at the bottom of every email.

You can configure these under Configuration () > System Settings > General Settings > Mail. The email templates consist of the following different elements:

Global Email CSS Styling
Global Email Header Content
Email Template Content
Global Email Signature
Global Email Footer Content

Disabling Templates

There may be circumstances when you want to disable certain emails from sending. For example, you might not want emails to go out after invoice creation or when a product is suspended.

To do this:

  1. Edit the email template you wish to disable.
  2. Check the Disable checkbox in the fields at the top of the page.
  3. Save your changes to the email.

That email won't send again until you reenable it.

Translating Email Templates

The default version under Configuration () > System Settings > Email Templates > Edit corresponds to the language you have selected in Configuration () > System Settings > General Settings > Localisation. You can translate the email templates and WHMCS will send emails in that language if the client chooses it during the order process:

  1. At the bottom of Configuration () > System Settings > Email Templates, select the language you wish to add from the Add menu.
  2. Edit each email template and a second text area will appear.
  3. Translate the email template into the selected language.

Clients who choose that language will now receive the translated emails.

Merge Fields

In email messages you can enter merge field variables, which the system replaces with the user's data when it sends the email.

The merge fields in your message depend on what type of email you are sending. For example, if it's an email for a client, you can include client fields only, but if it's a product-related email you could include product details as well as client fields.

The exact list of fields you have available in any email message appears directly below the message box with the field description and merge field code. Clicking on the description will insert the merge field at the point of your cursor in the message.

Addon Merge Fields

To display the Addon name in the welcome email, use the format {$addon_name}.

This will now allow you to send the name of the Addon the client purchased in your Welcome Emails for products.

Custom Fields

You can also display custom fields in emails by way of merge fields.

Custom Client Field

  • To display custom client fields in email templates, reference them by name using the format {$client_custom_field_fieldnamehere}.
  • For fieldnamehere, you need to convert the custom field name to lowercase and remove anything other than a–z and 0–9. For example, "VAT Number" would become vatnumber after removing the space, so the merge field would be {$client_custom_field_vatnumber} in the email template.

Product Custom Fields

  • To display product custom fields in email templates, reference them by name using the format {$service_custom_field_fieldnamehere}.
  • To display all the custom fields that apply to a product, you can use a foreach loop like this:
{foreach from=$service_custom_fields item=customfield}

Conditional Displays

You may want to display text in an email only under certain conditions. For example, you might want to include specific information in a sales support ticket submission.

To do this, use a conditional statement in the Support Ticket Opened email template. For example:

{if $ticket_department eq "Sales"}The sales department is open 9-5pm Monday-Friday so you
will only receive a response between these times. We thank you for your patience.{/if}

More information:

Custom PHP Logic

We recommend that you avoid the {php} tags in your custom email templates for security reasons. However, if you need to use them, we recommend using the EmailPreSend hook point to create your own Smarty merge fields to run your custom PHP logic.

Further Customisation

The email templates are Smarty template files. You can take advantage of the full range of Smarty syntax, just like the .tpl files, which control the appearance of the system. For more information, see our documentation.