Provide the ability to set custom headers on outgoing email messages
Parent Issue
No response
User Story
I want to be able to set the email "Reply-To" header in my dotCMS form notification messages to use the user-submitted email address from the form. Something like this
From: [email protected]
To: [email protected]
Reply-To: [email protected]
Subject: Dotcms contact form submission from [email protected]
So I can just hit "Reply" on received notification emails.
We should be able to add multiple, arbitrary, email headers - Reply-To is just a compelling example.
Before DKIM and other email security restrictions were in use, it was common to use the email address received on a web form submission as the "From" address on the notification email. This is no longer possible, so setting the Reply-To header is a common tactic.
Acceptance Criteria
Users can add arbitrary email headers using $mailer.sendEmail(), Workflow notifications, and any other mechanism I may not be aware of.
Users can use received form data as header values.
Proposed Objective
Please Select
Proposed Priority
Please Select
External Links... Slack Conversations, Support Tickets, Figma Designs, etc.
https://dotcms.zendesk.com/agent/tickets/110125
https://dotcms.slack.com/archives/CSHTYUR7H/p1677874072624659?thread_ts=1677867559.183739&cid=CSHTYUR7H
https://dotcms.slack.com/archives/CSHTYUR7H/p1677874591103319?thread_ts=1677874386.281699&cid=CSHTYUR7H
Assumptions & Initiation Needs
No response
Quality Assurance Notes & Workarounds
No response
Sub-Tasks & Estimates
No response
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Hi @fmontes, I think this issue needs to be looked at with new priority as it is a blocker for customer DB and high on the CX Priority list. Is this something that can be worked on in the next sprint or two? Thank you.
Educated guess of estimation one week. To take into account for priorization. cc: @mboutillette-dotcms
PRs:
- https://github.com/dotCMS/core/pull/31805
These are the workflow actions that support sending emails:
๐งช NOTE TO QA
๐ง How to Test
1. Set Up Your Google Account
(Skip this step if using another SMTP provider)
-
Go to Manage Google Account โ Security
-
Search for App Passwords and generate one
2. Configure Environment Variables
(Refer to the Mail Configuration Docs ):
DOT_MAIL_TRANSPORT_PROTOCOL: 'smtps'
DOT_MAIL_SMTPS_HOST: 'smtp.gmail.com'
DOT_MAIL_SMTPS_USER: 'YOUR-MAIL'
DOT_MAIL_SMTPS_PASSWORD: 'YOUR-APP-PASSWORD'
DOT_MAIL_SMTPS_AUTH: true
DOT_MAIL_SMTPS_PORT: 465
3. Set the New Property
For example:
DEFAULT_EMAIL_HEADERS = 'Reply-To:YOUR-MAIL, X-Custom-Header2:Value2'
4. Test Default Custom Headers
Verify that the DEFAULT_EMAIL_HEADERS are correctly applied to outgoing emails in the following scenarios:
โ Workflow Actions
-
Notify Assignee
-
Notify User
-
Async Send an Email
-
Send an Email
-
Multiple Approver
-
Four Eyes Approver
-
Send Form Email
โ Mailer View Tool
โ Reset Password
5. Test Custom Header Input Support
Verify that UI options to define custom headers manually are available in the following scenarios:
๐ Workflow Actions
-
Notify Assignee
-
Notify User
-
Async Send an Email
-
Send an Email
-
Multiple Approver
-
Four Eyes Approver
-
Send Form Email
6. Test Custom Headers in Mailer View Tool
Example usage in the Velocity playground:
#set($headerMap = {})
$!headerMap.put("Reply-To", "[email protected]")
$!headerMap.put("X-Priority", "1")
#set($error =
$mailer.sendEmail(
'[email protected]',
'[email protected]',
'The Subject',
'The Message',
false,
$headerMap
)
)
#if($UtilMethods.isSet($error))
## Custom Error Handling
#else
<p>Your message was sent</p>
#end
โ Expected Behavior
-
If
DEFAULT_EMAIL_HEADERSis set, all outgoing emails should include those headers by default. -
If custom headers are explicitly defined in a specific workflow action or view tool, only those should be included.
Looks good