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.
After clicking Send Welcome Email the following error is displayed:
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
- Navigate to Configuration > System Settings > Email Templates.
- Review the Email Templates and verify whether the email template is listed in the list of Email Templates.
- 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
- Access phpMyAdmin.
- Select the WHMCS database on the left hand side.
- Click on the table name
tblemailtemplates
. - Select the Operations tab, then rename the database to
tblemailtemplates_backup
. - Click GO to execute.
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`;
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.
- 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.
- Extract the contents of the WHMCS .zip file.
- Find the two .sql files to restore the default email templates at
/whmcs/resources/sql/install/
:tblemailtemplates.schema.sql
tblemailtemplates.data.sql
Creating a new tblemailtemplates table
The first file to import via phpMyAdmin is tblemailtemplates.schema.sql
.
- Access phpMyAdmin.
- Select the WHMCS database on the left hand side.
- Click on the Import tab.
- Using the Browse button, select the file
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.sql
. This file will restore all of the default email templates data back in to the table.
- Access phpMyAdmin.
- Select the WHMCS database on the left hand side.
- 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:
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.