Billionmail/BillionMail · error

failed to send test email to %d recipient(s): %v

Error message

failed to send test email to %d recipient(s): %v

What it means

After attempting Send to each recipient, sendTestEmailWithMailService collects failures in failedRecipients; if any recipient failed it returns an error listing the count and the per-recipient errors. The connection succeeded but message delivery failed for one or more addresses.

Source

Thrown at core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go:155

	var failedRecipients []string
	for _, recipient := range settings.RecipientList {

		message := mail_service.NewMessage(subject, body)
		message.SetRealName(settings.Name)
		messageId := sender.GenerateMessageID()
		message.SetMessageID(messageId)

		err = sender.Send(message, []string{recipient})
		if err != nil {
			g.Log().Errorf(ctx, "Failed to send test email to %s: %v", recipient, err)
			failedRecipients = append(failedRecipients, recipient)
		} else {
			g.Log().Infof(ctx, "Test email sent successfully to %s", recipient)
		}
	}

	if len(failedRecipients) > 0 {
		return fmt.Errorf("failed to send test email to %d recipient(s): %v", len(failedRecipients), failedRecipients)
	}

	g.Log().Infof(ctx, "Test email sent successfully to all %d recipients", len(settings.RecipientList))
	return nil
}

func buildTestEmailHTML(settings *v1.SetBlacklistAlertSettingsReq) string {
	return fmt.Sprintf(`
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Alert Settings Configured Successfully</title>
		<style>
			p {
				margin: 0;
			}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Check the wrapped recipient error list — it names each failed address and the SMTP rejection reason.
  2. Remove/correct invalid recipient addresses and retry the test.
  3. Ensure SenderEmail is a permitted From address on the SMTP account (spoofed-From rejection is common).
  4. Verify the SMTP account is allowed to relay to external domains.

Example fix

// before
recipientList: ["admin@example.cm"] // typo TLD, no MX
// after
recipientList: ["admin@example.com"]
Defensive patterns

Strategy: try-catch

Validate before calling

// validate every recipient's domain has MX before submitting
for (const r of recipientList) {
  const domain = r.split('@')[1]
  if (!domain || !(await hasMXRecord(domain))) throw new Error(`No MX for ${domain}: ${r}`)
}

Try / catch

err := SetBlacklistAlertSettings(ctx, req)
if err != nil && strings.Contains(err.Error(), "failed to send test email to") {
  // parse failed recipients from the error, report per-address reasons in UI
  var fe *FailedRecipientsError
  if errors.As(err, &fe) { reportPerRecipient(fe.Recipients) }
}

Prevention

When it happens

Trigger: SetBlacklistAlertSettings test send where sender.Send returns an error for at least one address in RecipientList (rejected recipient, relay denied, mailbox nonexistent, rate limit).

Common situations: Recipient domain has no MX record; SMTP server rejects relaying for unauthenticated senders; sender email not allowed by the provider; typo'd recipient address.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/3e5f1975878526cd. Report an issue: GitHub.