nopSolutions/nopCommerce · warning · NopException
Recipient email is not valid
Error message
Recipient email is not valid
What it means
Thrown in the GiftCard NotifyRecipient action when the persisted giftCard.RecipientEmail fails CommonHelper.IsValidEmail. Unlike most validation here, this validates data already stored on the gift card (not the posted form) — the recipient email was captured when the gift card was created or purchased. NopException, caught and shown as an error notification.
Source
Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/GiftCardController.cs:216
public virtual IActionResult GenerateCouponCode()
{
return Json(new { CouponCode = _giftCardService.GenerateGiftCardCode() });
}
[HttpPost, ActionName("Edit")]
[FormValueRequired("notifyRecipient")]
[CheckPermission(StandardPermission.Orders.GIFT_CARDS_CREATE_EDIT_DELETE)]
public virtual async Task<IActionResult> NotifyRecipient(GiftCardModel model)
{
//try to get a gift card with the specified id
var giftCard = await _giftCardService.GetGiftCardByIdAsync(model.Id);
if (giftCard == null)
return RedirectToAction("List");
try
{
if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
throw new NopException("Recipient email is not valid");
if (!CommonHelper.IsValidEmail(giftCard.SenderEmail))
throw new NopException("Sender email is not valid");
var languageId = 0;
var order = await _orderService.GetOrderByOrderItemAsync(giftCard.PurchasedWithOrderItemId ?? 0);
if (order != null)
{
var customerLang = await _languageService.GetLanguageByIdAsync(order.CustomerLanguageId) ?? (await _languageService.GetAllLanguagesAsync()).FirstOrDefault();
if (customerLang != null)
languageId = customerLang.Id;
}
else
{
languageId = _localizationSettings.DefaultAdminLanguageId;
}
View on GitHub (pinned to 64bdf2ff08)
Solutions
- Open the gift card record and correct the RecipientEmail to a valid address, then retry notification.
- Audit how the gift card was created — fix the upstream creation/purchase flow to validate recipient email at write time.
- Run a data check for gift cards with invalid RecipientEmail before bulk-notify operations.
- If this recurs, add IsValidEmail validation in the gift-card creation/purchase path.
Example fix
// before — notify fails because stored email is invalid
throw new NopException("Recipient email is not valid");
// after — validate and repair the gift card record before notifying
if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
{
_notificationService.ErrorNotification("Recipient email on this gift card is invalid; please correct it first.");
return RedirectToAction("Edit", new { id = giftCard.Id });
} Defensive patterns
Strategy: validation
Validate before calling
// Before notifying: validate the stored recipient email
if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
{
_notificationService.ErrorNotification("Recipient email on this gift card is invalid; correct it before notifying.");
return RedirectToAction("Edit", new { id = giftCard.Id });
} Type guard
bool HasValidRecipientEmail(GiftCard gc) => CommonHelper.IsValidEmail(gc?.RecipientEmail);
Try / catch
// The NotifyRecipient try/catch already shows exc.Message; pre-validate the stored email to avoid the error entirely.
Prevention
- Validate recipient email at gift-card creation/purchase time.
- Before bulk notify, filter gift cards whose RecipientEmail is invalid.
- Run a data-quality query on legacy gift cards imported without email checks.
When it happens
Trigger: POST to GiftCard/NotifyRecipient (with the notifyRecipient form value) for a gift card whose RecipientEmail column holds an invalid or empty email address.
Common situations: Gift cards created via migration/seed data without a valid recipient email; a checkout flow or custom integration that wrote a malformed recipient email; legacy gift cards created before email validation was enforced at creation time.
Related errors
- Sender email is not valid
- Email is not valid.
- You cannot delete this email account. At least one account i
- Template cannot be loaded
- Enter test email address
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/329eb36c8c647d89.
Report an issue: GitHub.