Email Templates

Email Templates in the Admin Area

WHMCS’s email templates allow you to customize 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.

You can access this feature at Configuration () > System Settings > Email Templates.

  • WHMCS’s email templates are Smarty template files. For more information about using and customizing the Smarty syntax, see our Developer Documentation.
  • If you accidentally delete an email template or cause a syntax error, you can restore the default email templates. For steps, see Restore Default Email Templates.

Editing Email Templates

To edit an email template, click the edit icon next to the template you want to change.

You can’t modify the sender and subject of the email support ticket email templates. They must use a specific format for the email piping feature to import email replies into the ticket system.
For more information, see Customize Email Templates.

Create a Custom Template

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. Click Create New Email Template.
    You can only create email templates for the types that you can manually send: General, Product, Domain, and Invoice.
  2. Compose the email subject and message in the displayed editor.
    • Use a unique name for the template so that you can identify it easily in menus. Only admins will see the name that you give it.
    • 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.
  3. Save your email template.

Adding an Attachment

An email template can contain attachments that the system includes each time that you send that email to clients.

To do this:

  1. Click Edit for the appropriate email template.
  2. Browse to the file that you want to attach and select it.
  3. Click Add More if you wish to attach more than one file. Repeat this for each file that you want to attach.
  4. Click Save Changes. The system will upload the files to your downloads directory.

Adding Headers and Footers

You can 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 in the Mail tab at Configuration () > System Settings > General Settings.

Translating Email Templates

The default language when you edit an email template corresponds to the language that you have selected in the Localisation tab at Configuration () > System Settings > General Settings.

You can translate the email templates and WHMCS will send emails in that language if the client chooses it during the order process.

To do this:

  1. Select the language that you wish to add for Add.
  2. Edit each email template. 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 that the system replaces with the user’s data when it sends the email.

The merge fields in your message depend on the type of email that 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 that the client purchased in your welcome emails for products.

Custom Fields

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

  • To display custom client fields in email templates, reference them by name using the format {$client_custom_field_fieldnamehere}.
    • For fieldnamehere, convert the custom field name to lowercase and remove anything other than az and 09.
    • 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.
  • 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. For example:
    {foreach from=$service_custom_fields item=customfield}
    {$customfield}
    {/foreach}
    

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. We thank you for your patience.
{/if}

Custom PHP Logic

We recommend that you avoid {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.

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 you have suspended a service.

To do this:

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

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

Last modified: June 14, 2024