Restoring Default Email Templates

Introduction

This guide demonstrates how to restore the Default Email Templates shipped with WHMCS. Any custom email templates can be recreated afterwards using the backup table we will create.

phpMyAdmin will be used in this guide when working with the database.

Example and Error

One may wish to restore the default email templates that come shipped with WHMCS if a syntax error prevents a message from being sent or if the email template was been deleted.

For the purposes of this guide, an Email Template Not Found error is encountered when attempting to resend the product welcome email for a client's service.

Resending Product Welcome EMail Error

After clicking Send Welcome Email the following error is displayed:

Email Sending Failed - Email Template Not Found

This error means the email template that is being used for the Service Welcome Email could not be found in the database.

All email templates used in WHMCS are stored in the database table tblemailtemplates.

Investigation

  1. Navigate to Configuration > System Settings > Email Templates.
  2. Review the Email Templates and verify whether the email template is listed in the list of Email Templates.
  3. If  it is not present, perform the steps below to restore the Default Email Templates under Resolution.

 

Resolution

Create a backup of the database before proceeding.

Rename the current tblemailtemplates database table to make a backup

  1. Access phpMyAdmin.
  2. Select the WHMCS database on the left hand side.
  3. Click on the table name tblemailtemplates.
  4. Select the Operations tab, then rename the database to tblemailtemplates_backup.
  5. Click GO to execute.
Rename tblemailtemplates to tblemailtemplates_backup

Alternatively, the below SQL statement will do the same thing and rename your table database name. One may wish to use the SQL tab via phpMyAdmin.

RENAME TABLE `tblemailtemplates` TO `tblemailtemplates_backup`;
Click to copy

Use either the phpmyadmin or SQL statement method, not both.

Gathering the necessary files

There are two files that are needed to restore the Default Email Templates.

  1. Download a fresh full release of the most current or the current version you are using from https://download.whmcs.com or from your reseller.
  2. Extract the contents of the WHMCS .zip file.
  3. Find the two .sql files to restore the default email templates at /whmcs/resources/sql/install/:
    • tblemailtemplates.schema.sql
    • tblemailtemplates.data.sql
tblemailtemplates data and schema files

Creating a new tblemailtemplates table

The first file to import via phpMyAdmin is tblemailtemplates.schema.sql .

  1. Access phpMyAdmin.
  2. Select the WHMCS database on the left hand side.
  3. Click on the Import tab.
  4. Using the Browse button, select the file tblemailtemplates.schema.sql.
Import tblemailtemplates.schema.sql

5.    Click on the GO button to the bottom-left side to execute importing the schema for the table tblemailtemplates.

Add the Email Template data into the new table

The last file to import via phpMyAdmin is tblemailtemplates.data.sqlThis file will restore all of the default email templates data back in to the table.

  1. Access phpMyAdmin.
  2. Select the WHMCS database on the left hand side.
  3. Find the table tblemailtemplates and click on it to enter this table.

You will see an empty table. We will now import the default email template data into the newly created tblemailtemplates table

4.    At the top, click on the Import tab and then click on Choose File.

5.    Select the tblemailtemplates.data.sql file.

6.  Click on the GO button to the bottom-left side to execute importing the default email template data.

 

If the import is successful, an Import has been successfully finished message will be displayed:

Import has been successfully finished

Custom Email Templates

To add any custom email templates, access the tblemailtemplates_backup table that was created at the beginning of this guide. Use that table to gather the data for the custom email templates and add them via the WHMCS admin UI under Configuration > System Settings > Email Templates.

Confirmation

Now, check the Email Templates under Configuration > System Settings > Email Templates and the default email templates will be back in the system.

View the Email Templates page

Success! This completes the guide on restoring the default Email Templates shipped with WHMCS back into the WHMCS database.