Legacy Knowledge Base
Published Jun. 30, 2025

Configuring Email Sender Name and Email Address in Liferay Workflows Notification

Written By

Daniel Martinez Cisneros

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • How to specify a custom email address or sender name for a workflow notification different from the default provided in portal.properties:
    workflow.email.from.name=test
    workflow.email.from.address=test@liferay.com
  •  

Environment

  • Quarterly releases
  • 7.3
  • 7.4

Resolution

Sender's name and email address are configured by default in the portal.properties:

workflow.email.from.name=
workflow.email.from.address=

If you wish to establish a different sender for each workflow, you can change the workflow context to provide those properties directly when executing the notification task: 

workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"newSenderName");
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"newSenderName@newSenderName.com");

To apply this change, follow the steps outlined below, based on the "Single approver" workflow:

  1. Open the workflow code and navigate to the "task" element to which you have associated the notification, for example, in the example shown, it would be the "review" task.
  2. Add a new node of type "action" in which you include the senderName and senderAddress in the context.
  3. Finally, you should set the workflowContext in the serviceContext.

Here's how to apply it:

<action>
<name>review</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"senderName");
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"sender.mail@liferay.com");
serviceContext.setAttribute("workflowContext", workflowContext);

]]>
</script>
<script-language>groovy</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>Review Notification</name>
<template>
<![CDATA[${userName} sent you a ${entryType} for review in the workflow.]]>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<assignees />
</recipients>
<execution-type>onAssignment</execution-type>
</notification>

 

The constants workflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME and workflowConstants.CONTEXT_NOTIFICATION_SENDER_EMAIL are read by the class EmailNotificationSender.java.

  • If they come from the workflow context, those will always be taken.
  • Otherwise, those configured in the properties we mentioned earlier are taken.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base