legacy-knowledge-base
公開されました Jun. 30, 2025

Liferay ワークフローの通知でメール送信者名とメールアドレスを設定する

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

learn-legacy-article-disclaimer-text

問題

  • portal.properties で提供されるデフォルトとは異なる、ワークフロー通知用のカスタム電子メールアドレスまたは送信者名を指定する方法:
    workflow.email.from.name=test
    workflow.email.from.address=test@liferay.com

環境

  • 四半期ごとのリリース
  • 7.3
  • 7.4

解像度

送信者の名前とメールアドレスは、デフォルトでportal.propertiesに設定されています:

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

ワークフローごとに異なる送信者を設定したい場合は、通知タスクの実行時にワークフローコンテキストを変更して、それらのプロパティを直接提供することができます:

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

この変更を適用するには、"Single approver "ワークフローに基づき、以下のステップに従ってください:

  1. ワークフロー・コードを開き、通知を関連付けた "タスク "エレメントに移動します。
  2. コンテキストにsenderNameとsenderAddressを含む "action "タイプの新しいノードを追加する。
  3. 最後に、serviceContext に workflowContext を設定する。

これがその適用方法だ:

<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>

定数workflowConstants.CONTEXT_NOTIFICATION_SENDER_NAMEと workflowConstants.CONTEXT_NOTIFICATION_SENDER_EMAILは、クラスEmailNotificationSender.javaで読み込まれます。

  • ワークフローコンテキストに由来するものであれば、それは常に採用される。
  • そうでない場合は、先に述べたプロパティで設定されたものが使われる。

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base