ComusThumbz Dokumentation
Admin-Anmeldung

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

Requirement Minimum Recommended
PHP Version 7.4+ 8.0+
Memory Limit 32M 64M

PHP Extensions Required

  • mysqli - Database connectivity
  • json - JSON encoding for template variables
  • date - Date formatting for statistics

Email Sending Requirements

 

Configuration Required:
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:

Card Color Description
Total Sent Green Total emails sent in last 30 days
Successful Blue Successfully delivered emails
Failed Red Failed delivery attempts
Queued Orange Emails waiting in queue

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

 

Note: Billing templates are sent automatically by the payment system.

 

Template Trigger
purchaseconfirmation After successful initial purchase
subscriptionrenewal After successful rebill
subscriptionexpiring X days before subscription expires
paymentfailed When rebill attempt fails

System Templates

 

Note: System templates handle user account lifecycle events.

 

Template Trigger
welcomeemail After user registration
passwordreset When user requests password reset
emailverification When email verification is required
accountsuspended When admin suspends an account

Marketing Templates

 

Note: Marketing templates are used for promotional campaigns.

 

Template Use Case
promotional Special offers, discounts, announcements

Template Variables

Templates use double-brace syntax for variables: {{variablename}}

Common Variables

Variable Description Example
{{username}} User's display name "John"
{{sitename}} Website name "MySite"
{{email}} User's email address "john@example.com"

Billing Variables

Variable Description Example
{{orderid}} Transaction ID "TXN-12345"
{{amount}} Purchase amount "$29.99"
{{packagename}} Subscription package "Premium Monthly"
{{expirydate}} Subscription expiry "January 15, 2025"
{{nextrenewaldate}} Next billing date "February 15, 2025"
{{renewallink}} Link to renew URL
{{updatepaymentlink}} Link to update payment URL

System Variables

Variable Description Example
{{loginlink}} Login page URL URL
{{resetlink}} Password reset URL URL with token
{{verificationlink}} Email verification URL URL with token
{{expirytime}} Link expiration time "24 hours"
{{reason}} Suspension reason "Terms violation"
{{appeallink}} Appeal/contact URL URL

Step-by-Step Usage

Editing a Template

  1. Navigate to Admin Panel → Settings → Email Templates
  2. Locate the template you want to edit
  3. Click the Edit button to expand the form
  4. Modify the Subject line
  5. Edit the HTML Body (use HTML formatting)
  6. Edit the Plain Text Body (fallback for text-only clients)
  7. Ensure Template Active is checked
  8. Click Save Template

Using Template Variables

  1. Open a template for editing
  2. Review the Available Variables section below the form
  3. Insert variables using double-brace syntax: {{variablename}}
  4. 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

  1. Open the template for editing
  2. Uncheck the Template Active checkbox
  3. Click Save Template

 

Warning: Disabling a billing template will prevent those emails from being sent. Users may not receive important notifications.

 

Viewing Email Statistics

  1. Statistics cards show 30-day performance
  2. Total Sent = All send attempts
  3. Successful = Confirmed deliveries (status = 'sent')
  4. Failed = Bounced or error emails
  5. 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

 

Tip: Follow these guidelines for effective emails:

 

  1. Subject Lines:
  • Keep under 50 characters
  • Include key information (order ID, action required)
  • Avoid spam trigger words
  1. HTML Body:
  • Use inline CSS styles
  • Keep design simple and mobile-friendly
  • Include unsubscribe links for marketing emails
  • Test in multiple email clients
  1. Plain Text Body:
  • Always provide a plain text version
  • Some users prefer text-only
  • Some email clients block HTML

Testing Templates

  1. Create a test user account
  2. Trigger the template action (purchase, password reset, etc.)
  3. Check the email in your inbox
  4. Verify variables are replaced correctly
  5. Test on desktop and mobile email clients

Template Maintenance

 

Tip: Regular template maintenance improves deliverability:

 

  1. Review templates quarterly
  2. Update outdated information
  3. Check links are working
  4. Monitor failed email statistics
  5. Remove unused marketing templates

Troubleshooting

Common Issues

Emails Not Being Sent

Cause: Email configuration issue or queue not processing

Solutions:

  1. Check PHP mail() function is enabled
  2. Verify SMTP settings in config.inc.php
  3. Ensure cron job is running (sitecron.php)
  4. Check tblEmailQueue for stuck emails
  5. Review server mail logs

 

Variables Not Replaced

Cause: Incorrect variable syntax

Solutions:

  1. Use exact syntax: {{variablename}}
  2. Check available variables for the template
  3. Ensure variable is passed when sending
  4. No spaces inside braces

 

High Failed Count

Cause: Invalid email addresses or server blocked

Solutions:

  1. Validate email addresses on registration
  2. Check if your server IP is blacklisted
  3. Consider using dedicated email service
  4. Review bounce messages in tblEmailLog

 

Emails Going to Spam

Cause: Poor sender reputation or content

Solutions:

  1. Set up SPF, DKIM, and DMARC records
  2. Use a reputable email service
  3. Avoid spam trigger words
  4. Include physical address (for marketing)
  5. Provide clear unsubscribe option

 

Database Issues

Templates Not Loading

Cause: Migration not run

Solutions:

  1. Run admin/sql/migrations/005emailtemplatessystem.sql
  2. Check tblEmailTemplates exists
  3. 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"
}


Version History

Version Date Changes
1.0.0 2025-10-15 Initial email templates system (Task 8.14.1)
1.1.0 2025-11-01 Added email queue processing
1.2.0 2025-12-01 Added email statistics dashboard
1.3.0 2025-12-15 Modern UI with green theme