diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java index d1dd4ae67c..dc06b0b9db 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java @@ -137,8 +137,12 @@ public class EmailServices { // check to see if we should redirect all mail for testing String redirectAddress = EntityUtilProperties.getPropertyValue("general", "mail.notifications.redirectTo", delegator); if (UtilValidate.isNotEmpty(redirectAddress)) { - String originalRecipients = " [To: " + sendTo + ", Cc: " + sendCc + ", Bcc: " + sendBcc + "]"; - subject += originalRecipients; + StringBuilder sb = new StringBuilder(); + sb.append(" [To: ").append(sendTo); + if (UtilValidate.isNotEmpty(sendCc)) sb.append(", Cc: ").append(sendCc); + if (UtilValidate.isNotEmpty(sendBcc)) sb.append(", Bcc: ").append(sendBcc); + sb.append("]"); + subject += sb.toString(); sendTo = redirectAddress; sendCc = null; sendBcc = null;