{"record":{"id":"77e1860e4f84d21c","repo":"nopSolutions/nopCommerce","slug":"email-is-not-valid-77e186","errorCode":null,"errorMessage":"Email is not valid","messagePattern":"Email is not valid","errorType":"validation","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":458,"sourceCode":"                {\r\n                    Address1 = pickupPoint.Address,\r\n                    City = pickupPoint.City,\r\n                    County = pickupPoint.County,\r\n                    CountryId = country?.Id,\r\n                    StateProvinceId = state?.Id,\r\n                    ZipPostalCode = pickupPoint.ZipPostalCode,\r\n                    CreatedOnUtc = DateTime.UtcNow\r\n                };\r\n            }\r\n            else\r\n            {\r\n                if (details.Customer.ShippingAddressId == null)\r\n                    throw new NopException(\"Shipping address is not provided\");\r\n\r\n                var shippingAddress = await _customerService.GetCustomerShippingAddressAsync(details.Customer);\r\n\r\n                if (!CommonHelper.IsValidEmail(shippingAddress?.Email))\r\n                    throw new NopException(\"Email is not valid\");\r\n\r\n                //clone shipping address\r\n                details.ShippingAddress = _addressService.CloneAddress(shippingAddress);\r\n\r\n                if (await _countryService.GetCountryByAddressAsync(details.ShippingAddress) is Country shippingCountry && !shippingCountry.AllowsShipping)\r\n                    throw new NopException($\"Country '{shippingCountry.Name}' is not allowed for shipping\");\r\n            }\r\n\r\n            var shippingOption = await _genericAttributeService.GetAttributeAsync<ShippingOption>(details.Customer,\r\n                NopCustomerDefaults.SelectedShippingOptionAttribute, processPaymentRequest.StoreId);\r\n            if (shippingOption != null)\r\n            {\r\n                details.ShippingMethodName = shippingOption.Name;\r\n                details.ShippingRateComputationMethodSystemName = shippingOption.ShippingRateComputationMethodSystemName;\r\n            }\r\n\r\n            details.ShippingStatus = ShippingStatus.NotYetShipped;\r\n        }\r","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L440-L476","documentation":"Thrown when the customer's shipping address (resolved via GetCustomerShippingAddressAsync) has an email that fails CommonHelper.IsValidEmail validation, including when the address or its Email field is null. nopCommerce requires a valid contact email on the shipping address for order confirmation and delivery notifications.","triggerScenarios":"The shipping address was created without an email field, the email contains invalid characters or format, the address record was imported from a migration with a missing/null Email column, or a guest entered a malformed email that bypassed earlier validation.","commonSituations":"Data migration from another platform where the email field wasn't mapped. A custom address-book import that omitted the email column. A guest customer who typed a partial email. An integration test using a placeholder address without setting Email.","solutions":["Update the shipping address record to include a valid email address before placing the order.","In checkout, ensure the shipping address form validates the email field before submission.","If migrating data, map the source email column to the nopCommerce Address.Email field.","For guest checkout, confirm the customer's primary email is propagated to the shipping address."],"exampleFix":"// before: shippingAddress.Email = null or \"not-an-email\"\n// after:\nshippingAddress.Email = customer.Email;\nawait _addressService.UpdateAddressAsync(shippingAddress);","handlingStrategy":"validation","validationCode":"// Before PlaceOrder, validate shipping address email\nvar shippingAddress = await _customerService.GetCustomerShippingAddressAsync(customer);\nif (!CommonHelper.IsValidEmail(shippingAddress?.Email))\n{\n    _notificationService.ErrorNotification(\"A valid email is required on the shipping address.\");\n    return RedirectToRoute(\"CheckoutShippingAddress\");\n}","typeGuard":"bool HasValidShippingEmail(Address addr) =>\n    addr != null && CommonHelper.IsValidEmail(addr.Email);","tryCatchPattern":"try\n{\n    var result = await _orderProcessingService.PlaceOrderAsync(processPaymentRequest);\n}\ncatch (NopException ex) when (ex.Message == \"Email is not valid\")\n{\n    // could be shipping or billing email; redirect to the relevant step\n    _notificationService.ErrorNotification(\"Please provide a valid email address.\");\n    return RedirectToRoute(\"CheckoutBillingAddress\");\n}","preventionTips":["Always include and validate an email field in address forms during checkout.","For guest checkout, propagate the customer email to both shipping and billing addresses automatically.","Run a data audit to find addresses with null/invalid Email and backfill them.","When importing customer data, map the source email field to Address.Email for all address types."],"tags":["nopcommerce","email-validation","shipping-address","validation","order-processing"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}