From bda4c4bdda7a552b7c7e656fc48156013e6136d0 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Fri, 13 Jul 2018 14:47:37 +0200 Subject: [PATCH] fixed #397 --- .../workflow/engine/plugins/MailPlugin.java | 22 +++++++++++-------- .../markdown/engine/plugins/mailplugin.md | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java index da12e105a..7f7205c48 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java @@ -250,17 +250,23 @@ public void close(boolean rollbackTransaction) throws PluginException { } /** - * Computes the sender name. This method can be overwritten by subclasses. + * Computes the sender name. A sender can be defined by the event property + * 'namMailFrom' or by the system property 'mail.defaultSender'. If no sender is + * defined, the method takes the current username. + * + * This method can be overwritten by subclasses. * * @param documentContext * @param documentActivity - * @return String - mail subject + * @return String - mail seder */ public String getFrom(ItemCollection documentContext, ItemCollection documentActivity) { - String sFrom = null; - // test if default sender is defined - if (getWorkflowService().getPropertyService() != null) { + // test if namMailReplyToUser is defined by event + String sFrom = documentActivity.getItemValueString("namMailFrom"); + + // if no from was defined by teh event, we test if a default sender is defined + if (sFrom.isEmpty() && getWorkflowService().getPropertyService() != null) { sFrom = (String) getWorkflowService().getPropertyService().getProperties().get("mail.defaultSender"); } // if no default sender take the current username @@ -518,8 +524,7 @@ public void initMailMessage() throws AddressException, MessagingException { * The method can be overwritten by subclasses to return a different * mail-address name or lookup a mail attribute in a directory. * - * @param aAddr - * string + * @param aAddr string * @return InternetAddress * @throws AddressException */ @@ -548,8 +553,7 @@ public InternetAddress getInternetAddress(String aAddr) throws AddressException * This method transforms a vector of E-Mail addresses into an InternetAddress * Array. Null values will be removed from list * - * @param String - * List of adresses + * @param String List of adresses * @return array of InternetAddresses */ @SuppressWarnings("rawtypes") diff --git a/src/site/markdown/engine/plugins/mailplugin.md b/src/site/markdown/engine/plugins/mailplugin.md index fbd18cca7..1fedf592e 100644 --- a/src/site/markdown/engine/plugins/mailplugin.md +++ b/src/site/markdown/engine/plugins/mailplugin.md @@ -149,9 +149,9 @@ The following event properties are supported: |Name |Type | Description | |----------------------|-----------|-----------------------------------------------| | txtMailSubject | String | Mail Subject | -| rtfMailBody | String | Mail Body (can be plain text or HTML | +| rtfMailBody | String | Mail Body (can be plain text or HTML) | | namMailReplyToUser | String | Reply To address. If not set the reply address is the sender address | -| namMailReceiver | String (list) | Receiver list (TO) | +| namMailFrom | String | Sender (default is the current user) | | namMailReceiver | String (list) | Receiver list (TO) | | namMailReceiverCC | String (list) | Receiver list (CC) | | namMailReceiverBCC | String (list) | Receiver list (BCC) |