Email Templates
WHMCS's 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.
You can access this feature at Configuration () > System Settings > Email Templates or, prior to WHMCS 8.0, Setup > Email Templates.
Contents
Editing Email Templates
To edit an email template, click the edit icon next to the template you want to change.
From the editor page, you can also toggle plain text and HTML email sending.
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.
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:
- 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.
- 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 Messages/Emails.
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.
To do this:
- Click Edit next to the appropriate email template.
- On your computer, browse to the file that you want to attach and select it.
- Click Add More if you wish to attach more than one file and repeat step 2.
- Click Save Changes. The system will upload the files to your downloads directory.
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 the Mail tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings. 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:
- Edit the email template you wish to disable.
- Check the Disable checkbox in the fields at the top of the page.
- Save your changes to the email.
That email won't send again until you reenable it.
Translating Email Templates
The default language when you edit an email template corresponds to the language you have selected in the Localisation tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > 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:
- Select the language you wish to add from the Add menu.
- Edit each email template and a second text area will appear.
- 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}
{$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 so you
will only receive a response between these times. We thank you for your patience.{/if}
More information: https://www.smarty.net/docs/en/language.function.if.tpl
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.