{"record":{"id":"b6fc616188e98036","repo":"nopSolutions/nopCommerce","slug":"sender-email-is-not-valid","errorCode":null,"errorMessage":"Sender email is not valid","messagePattern":"Sender email is not valid","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"warning","filePath":"src/Presentation/Nop.Web/Areas/Admin/Controllers/GiftCardController.cs","lineNumber":219,"sourceCode":"    }\n\n    [HttpPost, ActionName(\"Edit\")]\n    [FormValueRequired(\"notifyRecipient\")]\n    [CheckPermission(StandardPermission.Orders.GIFT_CARDS_CREATE_EDIT_DELETE)]\n    public virtual async Task<IActionResult> NotifyRecipient(GiftCardModel model)\n    {\n        //try to get a gift card with the specified id\n        var giftCard = await _giftCardService.GetGiftCardByIdAsync(model.Id);\n        if (giftCard == null)\n            return RedirectToAction(\"List\");\n\n        try\n        {\n            if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))\n                throw new NopException(\"Recipient email is not valid\");\n\n            if (!CommonHelper.IsValidEmail(giftCard.SenderEmail))\n                throw new NopException(\"Sender email is not valid\");\n\n            var languageId = 0;\n            var order = await _orderService.GetOrderByOrderItemAsync(giftCard.PurchasedWithOrderItemId ?? 0);\n\n            if (order != null)\n            {\n                var customerLang = await _languageService.GetLanguageByIdAsync(order.CustomerLanguageId) ?? (await _languageService.GetAllLanguagesAsync()).FirstOrDefault();\n                if (customerLang != null)\n                    languageId = customerLang.Id;\n            }\n            else\n            {\n                languageId = _localizationSettings.DefaultAdminLanguageId;\n            }\n\n            var queuedEmailIds = await _workflowMessageService.SendGiftCardNotificationAsync(giftCard, languageId);\n            if (queuedEmailIds.Any())\n            {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Controllers/GiftCardController.cs#L201-L237","documentation":"Thrown in the GiftCard NotifyRecipient action when the persisted giftCard.SenderEmail fails CommonHelper.IsValidEmail. This checks the sender email stored on the gift card (set at creation/purchase), not a posted form value. NopException, caught and shown as an error notification.","triggerScenarios":"POST to GiftCard/NotifyRecipient for a gift card whose SenderEmail column holds an invalid or empty address — reached only after the recipient email check passes.","commonSituations":"Gift cards created by a customer whose email was malformed or null in the customer record at purchase time; seed/migration data with blank sender emails; a customized gift-card creation flow that bypassed sender-email validation.","solutions":["Correct the SenderEmail on the gift card record, then retry.","Trace the purchase/creation path that wrote the sender email and ensure it validates against a valid customer email.","Add IsValidEmail validation at gift-card creation to prevent future bad data.","For bulk operations, pre-filter gift cards whose SenderEmail is invalid."],"exampleFix":"// before — notify fails because stored sender email is invalid\nthrow new NopException(\"Sender email is not valid\");\n\n// after — guard before attempting notification\nif (!CommonHelper.IsValidEmail(giftCard.SenderEmail))\n{\n    _notificationService.ErrorNotification(\"Sender email on this gift card is invalid; please correct it first.\");\n    return RedirectToAction(\"Edit\", new { id = giftCard.Id });\n}","handlingStrategy":"validation","validationCode":"// Before notifying: validate the stored sender email\nif (!CommonHelper.IsValidEmail(giftCard.SenderEmail))\n{\n    _notificationService.ErrorNotification(\"Sender email on this gift card is invalid; correct it before notifying.\");\n    return RedirectToAction(\"Edit\", new { id = giftCard.Id });\n}","typeGuard":"bool HasValidSenderEmail(GiftCard gc) => CommonHelper.IsValidEmail(gc?.SenderEmail);","tryCatchPattern":"// NotifyRecipient's try/catch shows exc.Message; pre-check both sender and recipient emails before sending.","preventionTips":["Ensure the purchasing customer's email is validated before creating a gift card.","Validate SenderEmail at creation time, not just at notify time.","Pre-screen gift cards in bulk operations for invalid sender/recipient emails."],"tags":["nopcommerce","admin","gift-card","email","validation","stored-data"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}