Add backend settings for email subject/message and token support for configuration change notifications

Created on 2 September 2025, 19 days ago

Problem/Motivation

Currently, when configuration changes occur, there is no way to customize the
email subject and message body for notification emails.

This makes it difficult for site administrators to:

  • Provide meaningful email notifications to their team.
  • Personalize emails with relevant contextual information.
  • Maintain consistent communication standards for their organization.

Steps to reproduce

  1. Enable the Configuration Logs module (or the custom module in question).
  2. Trigger a configuration change (e.g., update site name or a view).
  3. Observe that notifications are sent with hardcoded or non-configurable email content.
  4. Notice there’s no way to add tokens (like [site:name]) in the messages.

Proposed resolution

  • Add backend configuration settings to customize:
    • Email Subject
    • Email Body (with support for HTML and/or plaintext)
  • Integrate Drupal Token module to allow tokens in both subject and body fields.
  • Provide a preview option for admin users to see email output.
  • Ensure these settings are exportable to configuration (YAML) for deployment workflows.

Remaining tasks

  • Add new config schema for email subject and body.
  • Add a configuration form in the module’s admin UI.
  • Integrate token module and token browser for easy token selection.
  • Update mail send functionality to use these new settings.
  • Write tests to verify token replacement and email delivery.
  • Update documentation.

User interface changes

  • Add new fields in the module’s admin configuration page:
    • “Notification Email Subject” (Textfield with token support)
    • “Notification Email Body” (Textarea with token support)
  • Add a “Preview” button to render tokens in real time.

API changes

  • Expose a new hook_config_logs_mail_alter() or similar hook to allow other modules
    to modify the email subject/body programmatically.
  • Add a new service for generating tokenized messages.

Data model changes

A new configuration entity or settings array will be added to store the subject and body templates:

config_logs.settings:
  email_subject: 'Configuration changed: [config:name]'
  email_body: 'Hello [user:name], The configuration [config:name] was changed on [site:name].'
Feature request
Status

Active

Version

4.0

Component

Code

Created by

🇮🇳India someshver Panchkula

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024