nopSolutions/nopCommerce · error · NopException

Email is not valid

Error message

Email is not valid

What it means

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.

Source

Thrown at src/Libraries/Nop.Services/Orders/OrderProcessingService.cs:458

                {
                    Address1 = pickupPoint.Address,
                    City = pickupPoint.City,
                    County = pickupPoint.County,
                    CountryId = country?.Id,
                    StateProvinceId = state?.Id,
                    ZipPostalCode = pickupPoint.ZipPostalCode,
                    CreatedOnUtc = DateTime.UtcNow
                };
            }
            else
            {
                if (details.Customer.ShippingAddressId == null)
                    throw new NopException("Shipping address is not provided");

                var shippingAddress = await _customerService.GetCustomerShippingAddressAsync(details.Customer);

                if (!CommonHelper.IsValidEmail(shippingAddress?.Email))
                    throw new NopException("Email is not valid");

                //clone shipping address
                details.ShippingAddress = _addressService.CloneAddress(shippingAddress);

                if (await _countryService.GetCountryByAddressAsync(details.ShippingAddress) is Country shippingCountry && !shippingCountry.AllowsShipping)
                    throw new NopException($"Country '{shippingCountry.Name}' is not allowed for shipping");
            }

            var shippingOption = await _genericAttributeService.GetAttributeAsync<ShippingOption>(details.Customer,
                NopCustomerDefaults.SelectedShippingOptionAttribute, processPaymentRequest.StoreId);
            if (shippingOption != null)
            {
                details.ShippingMethodName = shippingOption.Name;
                details.ShippingRateComputationMethodSystemName = shippingOption.ShippingRateComputationMethodSystemName;
            }

            details.ShippingStatus = ShippingStatus.NotYetShipped;
        }

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Update the shipping address record to include a valid email address before placing the order.
  2. In checkout, ensure the shipping address form validates the email field before submission.
  3. If migrating data, map the source email column to the nopCommerce Address.Email field.
  4. For guest checkout, confirm the customer's primary email is propagated to the shipping address.

Example fix

// before: shippingAddress.Email = null or "not-an-email"
// after:
shippingAddress.Email = customer.Email;
await _addressService.UpdateAddressAsync(shippingAddress);
Defensive patterns

Strategy: validation

Validate before calling

// Before PlaceOrder, validate shipping address email
var shippingAddress = await _customerService.GetCustomerShippingAddressAsync(customer);
if (!CommonHelper.IsValidEmail(shippingAddress?.Email))
{
    _notificationService.ErrorNotification("A valid email is required on the shipping address.");
    return RedirectToRoute("CheckoutShippingAddress");
}

Type guard

bool HasValidShippingEmail(Address addr) =>
    addr != null && CommonHelper.IsValidEmail(addr.Email);

Try / catch

try
{
    var result = await _orderProcessingService.PlaceOrderAsync(processPaymentRequest);
}
catch (NopException ex) when (ex.Message == "Email is not valid")
{
    // could be shipping or billing email; redirect to the relevant step
    _notificationService.ErrorNotification("Please provide a valid email address.");
    return RedirectToRoute("CheckoutBillingAddress");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/77e1860e4f84d21c. Report an issue: GitHub.