You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2026/08/07 05:33:09 UTC

(ofbiz-framework) branch release24.09 updated: Fixed: sendFailureNotification NPEs on default sendFrom, masking the original SMTP error (OFBIZ-13477) (#1549)

This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new a7fb46af16 Fixed: sendFailureNotification NPEs on default sendFrom, masking the original SMTP error (OFBIZ-13477) (#1549)
a7fb46af16 is described below

commit a7fb46af166b8725fbcd353b67a88b48dc67a86a
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Fri Aug 7 11:03:03 2026 +0530

    Fixed: sendFailureNotification NPEs on default sendFrom, masking the original SMTP error (OFBIZ-13477) (#1549)
    
    sendFailureNotification() built its bounce-notification context from the raw, unresolved context.get("sendFrom") instead of the sendFrom local variable that sendMail() resolves (with a fallback to general.defaultFromEmailAddress). When a caller relied on that default, sendFrom/sendTo in the notification context were both null, causing an NPE in mail.addRecipients() that masked the original SMTP address failure and rolled back the transaction. This passes the already-resolved sendFrom  [...]
---
 .../main/java/org/apache/ofbiz/common/email/EmailServices.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 3f01063faa..32d124c201 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
@@ -362,7 +362,7 @@ public class EmailServices {
             }
             Boolean sendFailureNotification = (Boolean) context.get("sendFailureNotification");
             if (sendFailureNotification == null || sendFailureNotification) {
-                sendFailureNotification(ctx, context, mail, failedAddresses);
+                sendFailureNotification(ctx, context, mail, failedAddresses, sendFrom);
                 results.put("messageWrapper", new MimeMessageWrapper(session, mail));
                 try {
                     results.put("messageId", mail.getMessageID());
@@ -687,13 +687,13 @@ public class EmailServices {
         return sendMailFromScreen(dctx, serviceContext);
     }
     public static void sendFailureNotification(DispatchContext dctx, Map<String, ? extends Object> context, MimeMessage message,
-                                               List<SMTPAddressFailedException> failures) {
+                                               List<SMTPAddressFailedException> failures, String sendFrom) {
         Locale locale = (Locale) context.get("locale");
         Map<String, Object> newContext = new LinkedHashMap<>();
         newContext.put("userLogin", context.get("userLogin"));
         newContext.put("sendFailureNotification", false);
-        newContext.put("sendFrom", context.get("sendFrom"));
-        newContext.put("sendTo", context.get("sendFrom"));
+        newContext.put("sendFrom", sendFrom);
+        newContext.put("sendTo", sendFrom);
         newContext.put("subject", UtilProperties.getMessage(RESOURCE, "CommonEmailSendUndeliveredMail", locale));
         StringBuilder sb = new StringBuilder();
         sb.append(UtilProperties.getMessage(RESOURCE, "CommonEmailDeliveryFailed", locale));