core icon indicating copy to clipboard operation
core copied to clipboard

Provide the ability to set custom headers on outgoing email messages

Open yolabingo opened this issue 3 years ago โ€ข 7 comments

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

yolabingo avatar Mar 03 '23 20:03 yolabingo

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.

github-actions[bot] avatar Jun 08 '23 02:06 github-actions[bot]

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.

mboutillette-dotcms avatar Mar 20 '25 21:03 mboutillette-dotcms

Educated guess of estimation one week. To take into account for priorization. cc: @mboutillette-dotcms

fmontes avatar Mar 20 '25 23:03 fmontes

PRs:

  • https://github.com/dotCMS/core/pull/31805

github-actions[bot] avatar Apr 01 '25 16:04 github-actions[bot]

These are the workflow actions that support sending emails:

Image

nollymar avatar Apr 02 '25 22:04 nollymar

๐Ÿงช 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

Custom Header UI Example


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_HEADERS is 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.

valentinogiardino avatar Apr 07 '25 11:04 valentinogiardino

Looks good

fabrizzio-dotCMS avatar Apr 07 '25 19:04 fabrizzio-dotCMS