Email Templates
Overview
The Email Templates Management page allows administrators to customize all system-generated emails including billing notifications, user communications, and marketing messages. Each template supports both HTML and plain text versions with variable substitution for dynamic content.
Key capabilities include:
- View and edit email templates by category (billing, system, marketing)
- Customize email subjects and body content
- Enable/disable individual templates
- Use template variables for dynamic content
- View email delivery statistics (30-day window)
- Monitor email queue status
System Requirements
PHP Requirements
PHP Extensions Required
mysqli- Database connectivityjson- JSON encoding for template variablesdate- Date formatting for statistics
Email Sending Requirements
The email system requires proper mail configuration in PHP or an SMTP service:
- PHP
mail()function enabled, OR - SMTP server configured in config.inc.php
- Recommended: Dedicated email service (SendGrid, Mailgun, Amazon SES)
Installation Requirements
Cron Job (Email Queue Processing)
# Process email queue every minute (via sitecron.php)
php /path/to/ct/admin/cron/sitecron.php
The sitecron.php includes email queue processing in its tasks.
Features & UI Elements
Page Header
[Screenshot: email-templates-header]
The page header displays:
- Title: "Email Templates"
- Breadcrumb: Dashboard / Email Templates
Alert Messages
Success and error messages appear below the header:
- Success (green): "Template updated successfully!"
- Error (red): "Invalid security token. Please try again."
Email Statistics (30-Day Window)
[Screenshot: email-templates-stats]
Four statistics cards show email performance:
Templates List
[Screenshot: email-templates-list]
Templates are displayed as expandable cards with:
Card Header:
- Type Badge: billing (blue), system (purple), or marketing (yellow)
- Template Name: Human-readable name
- Description: Brief explanation of when template is used
- Status Badge: Active (green) or Inactive (red)
- Edit Button: Expands the template for editing
Card Body (Expanded):
- Subject input field
- HTML body textarea
- Plain text body textarea
- Available variables display
- Active checkbox
- Save button
- Last updated timestamp
Template Types
Billing Templates
System Templates
Marketing Templates
Template Variables
Templates use double-brace syntax for variables: {{variablename}}
Common Variables
Billing Variables
System Variables
Step-by-Step Usage
Editing a Template
- Navigate to Admin Panel → Settings → Email Templates
- Locate the template you want to edit
- Click the Edit button to expand the form
- Modify the Subject line
- Edit the HTML Body (use HTML formatting)
- Edit the Plain Text Body (fallback for text-only clients)
- Ensure Template Active is checked
- Click Save Template
Using Template Variables
- Open a template for editing
- Review the Available Variables section below the form
- Insert variables using double-brace syntax:
{{variablename}} - Variables are replaced with actual values when email is sent
Example HTML:
<h1>Welcome, {{username}}!</h1>
<p>Thank you for joining {{sitename}}.</p>
<p><a href="{{loginlink}}">Click here to log in</a></p>
Example Plain Text:
Welcome, {{username}}!
Thank you for joining {{sitename}}.
Log in here: {{loginlink}}
Disabling a Template
- Open the template for editing
- Uncheck the Template Active checkbox
- Click Save Template
Viewing Email Statistics
- Statistics cards show 30-day performance
- Total Sent = All send attempts
- Successful = Confirmed deliveries (status = 'sent')
- Failed = Bounced or error emails
- Queued = Pending in email queue
Monitoring the Email Queue
The Queued statistic shows emails waiting to be sent:
- High queue count may indicate email service issues
- Queue is processed by the cron job every minute
- Failed emails are retried up to 3 times
Best Practices
Email Content
- Subject Lines:
- Keep under 50 characters
- Include key information (order ID, action required)
- Avoid spam trigger words
- HTML Body:
- Use inline CSS styles
- Keep design simple and mobile-friendly
- Include unsubscribe links for marketing emails
- Test in multiple email clients
- Plain Text Body:
- Always provide a plain text version
- Some users prefer text-only
- Some email clients block HTML
Testing Templates
- Create a test user account
- Trigger the template action (purchase, password reset, etc.)
- Check the email in your inbox
- Verify variables are replaced correctly
- Test on desktop and mobile email clients
Template Maintenance
- Review templates quarterly
- Update outdated information
- Check links are working
- Monitor failed email statistics
- Remove unused marketing templates
Troubleshooting
Common Issues
Emails Not Being Sent
Cause: Email configuration issue or queue not processing
Solutions:
- Check PHP
mail()function is enabled - Verify SMTP settings in config.inc.php
- Ensure cron job is running (sitecron.php)
- Check tblEmailQueue for stuck emails
- Review server mail logs
Variables Not Replaced
Cause: Incorrect variable syntax
Solutions:
- Use exact syntax:
{{variablename}} - Check available variables for the template
- Ensure variable is passed when sending
- No spaces inside braces
High Failed Count
Cause: Invalid email addresses or server blocked
Solutions:
- Validate email addresses on registration
- Check if your server IP is blacklisted
- Consider using dedicated email service
- Review bounce messages in tblEmailLog
Emails Going to Spam
Cause: Poor sender reputation or content
Solutions:
- Set up SPF, DKIM, and DMARC records
- Use a reputable email service
- Avoid spam trigger words
- Include physical address (for marketing)
- Provide clear unsubscribe option
Database Issues
Templates Not Loading
Cause: Migration not run
Solutions:
- Run
admin/sql/migrations/005emailtemplatessystem.sql - Check tblEmailTemplates exists
- Verify database connection
Translatable Strings
{
"emailtemplatestitle": "Email Templates",
"emailtemplatesbreadcrumb": "Dashboard / Email Templates",
"emailtemplatessection": "Email Templates",
"emailtemplatessubject": "Email Subject",
"emailtemplateshtmlbody": "HTML Body",
"emailtemplatestextbody": "Plain Text Body",
"emailtemplatesvariables": "Available Variables",
"emailtemplatesactive": "Template Active",
"emailtemplatessave": "Save Template",
"emailtemplatesedit": "Edit",
"emailtemplateslastupdated": "Last Updated",
"emailtemplatessuccess": "Template updated successfully!",
"emailtemplateserrorcsrf": "Invalid security token. Please try again.",
"emailtemplateserrorupdate": "Failed to update template",
"emailtemplatesempty": "No email templates found.",
"emailtemplatesemptyhint": "Please run: admin/sql/migrations/005emailtemplatessystem.sql",
"emailstatstotal": "Total Sent (30 days)",
"emailstatssuccessful": "Successful",
"emailstatsfailed": "Failed",
"emailstatsqueued": "Queued",
"emailtypebilling": "billing",
"emailtypesystem": "system",
"emailtypemarketing": "marketing",
"emailstatusactive": "Active",
"emailstatusinactive": "Inactive"
}
Related Documentation
- Payment Providers - Payment processor configuration
- User Management - User account management
- System Settings - Global configuration
- Cron Jobs - Automated task scheduling