Skip to content

feat(core): provide the ability to set custom headers on outgoing email messages #24278 #31805

Merged
valentinogiardino merged 19 commits into
mainfrom
issue-24278-provide-the-ability-to-set-custom-headers-on-outgoing-email-messages
Apr 5, 2025
Merged

feat(core): provide the ability to set custom headers on outgoing email messages #24278 #31805
valentinogiardino merged 19 commits into
mainfrom
issue-24278-provide-the-ability-to-set-custom-headers-on-outgoing-email-messages

Conversation

@valentinogiardino
Copy link
Copy Markdown
Contributor

@valentinogiardino valentinogiardino commented Apr 1, 2025

Proposed Changes

  • Introduced a new enum, WorkflowParameter, in WorkflowParameter.java to centralize common workflow actionlet parameters. This enum now defines the CUSTOM_HEADERS parameter with its key, description, default value, and requirement status.

  • Updated various workflow actionlets—such as EmailActionlet, FourEyeApproverActionlet, MultipleApproverActionlet, NotifyAssigneeActionlet, NotifyUsersActionlet, and SendFormEmailActionlet—to utilize the new WorkflowParameter.CUSTOM_HEADERS. This change standardizes how custom email headers are defined and extracted.

  • MailerTool Update: Updated the MailerTool to support customHeaders, ensuring that custom header functionality is available across all email-related tools.

  • Modified the Mailer class to encapsulate header application logic in an applyHeaders method. This method now dynamically loads the system-wide default email headers via the new ConfigUtils.getDefaultEmailHeaders() method, allowing the default headers configuration to be changed at runtime.

  • New Config Property: Added the DEFAULT_EMAIL_HEADERS configuration property. This property allows administrators to define system-wide email header defaults (formatted as a comma-separated list of header key/value pairs, e.g., "X-Custom-1:Value1, X-Custom-2:Value2"). When no custom headers are provided at the workflow level, these defaults are applied to all outgoing emails.

  • Included additional validation and logging to capture and report any header parsing errors or invalid header lines.

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

This feature allows users to specify custom headers for workflow-triggered emails, useful for adding metadata or integration purposes (e.g., tracking headers, priority indicators).

Screenshots

Notify Assignee

image

Notify user

image

Async Send an Email

image

Send an Email

image

Multiple Approver

image

Four Eyes Approver

image

Send Form email

image

Mailer View Tool

image

Reset Password

image

This PR fixes: #24278

@dotcms-github-app
Copy link
Copy Markdown

Please use a Conventional Commit title format for this PR. For more information, see https://www.conventionalcommits.org/en/v1.0.0/

@valentinogiardino valentinogiardino changed the title Issue 24278 provide the ability to set custom headers on outgoing email messages feat(core): provide the ability to set custom headers on outgoing email messages #24278 Apr 1, 2025
@valentinogiardino valentinogiardino marked this pull request as ready for review April 1, 2025 17:26
Comment thread dotCMS/src/main/java/com/dotmarketing/util/EmailUtils.java Outdated
Comment thread dotCMS/src/main/java/com/dotmarketing/util/EmailUtils.java Outdated
Comment thread dotCMS/src/main/java/com/dotmarketing/util/Mailer.java Outdated
@valentinogiardino valentinogiardino marked this pull request as draft April 3, 2025 21:10
@valentinogiardino valentinogiardino marked this pull request as ready for review April 4, 2025 13:17
@nollymar nollymar added this pull request to the merge queue Apr 4, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 4, 2025
@valentinogiardino valentinogiardino added this pull request to the merge queue Apr 5, 2025
Merged via the queue into main with commit 99df600 Apr 5, 2025
37 checks passed
@valentinogiardino valentinogiardino deleted the issue-24278-provide-the-ability-to-set-custom-headers-on-outgoing-email-messages branch April 5, 2025 19:41
spbolton pushed a commit that referenced this pull request Jun 20, 2025
…il messages #24278  (#31805)

### Proposed Changes
- Introduced a new enum, `WorkflowParameter`, in
`WorkflowParameter.java` to centralize common workflow actionlet
parameters. This enum now defines the `CUSTOM_HEADERS` parameter with
its key, description, default value, and requirement status.
 
- Updated various workflow actionlets—such as `EmailActionlet`,
`FourEyeApproverActionlet`, `MultipleApproverActionlet`,
`NotifyAssigneeActionlet`, `NotifyUsersActionlet`, and
`SendFormEmailActionlet`—to utilize the new
`WorkflowParameter.CUSTOM_HEADERS`. This change standardizes how custom
email headers are defined and extracted.
 
- **MailerTool Update:** Updated the `MailerTool` to support
`customHeaders`, ensuring that custom header functionality is available
across all email-related tools.
 
- Modified the `Mailer` class to encapsulate header application logic in
an `applyHeaders` method. This method now dynamically loads the
system-wide default email headers via the new
`ConfigUtils.getDefaultEmailHeaders()` method, allowing the default
headers configuration to be changed at runtime.
 
- **New Config Property:** Added the `DEFAULT_EMAIL_HEADERS`
configuration property. This property allows administrators to define
system-wide email header defaults (formatted as a comma-separated list
of header key/value pairs, e.g., `"X-Custom-1:Value1,
X-Custom-2:Value2"`). When no custom headers are provided at the
workflow level, these defaults are applied to all outgoing emails.
 
- Included additional validation and logging to capture and report any
header parsing errors or invalid header lines.

### Checklist
- [x] Tests
- [x] Translations
- [x] Security Implications Contemplated (add notes if applicable)

### Additional Info
This feature allows users to specify custom headers for
workflow-triggered emails, useful for adding metadata or integration
purposes (e.g., tracking headers, priority indicators).

### Screenshots
#### Notify Assignee

![image](https://github.com/user-attachments/assets/1f251e6e-d821-4765-b6d8-f4ea4aa424a4)
#### Notify user

![image](https://github.com/user-attachments/assets/a174dbe7-8342-4633-ba4a-85f2e7940ba7)
#### Async Send an Email

![image](https://github.com/user-attachments/assets/00277741-14e9-4289-9a98-71999bd710c2)
#### Send an Email

![image](https://github.com/user-attachments/assets/b9b8d719-4581-4b55-9eb3-d59e201eea3d)
#### Multiple Approver

![image](https://github.com/user-attachments/assets/8e7abfcb-912d-45d0-bbb1-f4bf52769cf9)
#### Four Eyes Approver

![image](https://github.com/user-attachments/assets/13a2c4ba-1da2-4dec-919a-2e2aae50a57b)
#### Send Form email

![image](https://github.com/user-attachments/assets/0affffbd-e831-46f8-816a-38b151d4cc31)
####  Mailer View Tool

![image](https://github.com/user-attachments/assets/1074c313-f33e-4c77-9cba-e30f1f8d6adc)
#### Reset Password

![image](https://github.com/user-attachments/assets/07589ae6-717b-41b5-88c8-47609ad9316d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide the ability to set custom headers on outgoing email messages

3 participants