RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-from-address

error-invalid-from-address

Error message

Invalid from address

What it means

checkAddressFormatAndThrow asserts that a 'from' address passes the same @rocket.chat/tools format check, and throws Meteor.Error('error-invalid-from-address', 'Invalid from address') with the offending function name in the error details. It is the guard Mailer.sendMail (and other mail paths) run on the sender address before doing any work.

Source

Thrown at apps/meteor/server/lib/notifications/email/api.ts:217

}): Promise<void> =>
	sendNoWrap({
		to,
		from,
		replyTo,
		subject: replace(subject, data),
		text: (text && replace(text, data)) || (html && stripHtml(replace(html, data)).result) || undefined,
		html: html ? wrap(html, data) : undefined,
		headers,
	});

// Needed because of https://github.com/microsoft/TypeScript/issues/36931
type Assert = (input: string, func: string) => asserts input;
export const checkAddressFormatAndThrow: Assert = (from: string, func: string): asserts from => {
	if (checkAddressFormat(from)) {
		return;
	}

	throw new Meteor.Error('error-invalid-from-address', 'Invalid from address', {
		function: func,
	});
};

export const getHeader = (): string | undefined => contentHeader;

export const getFooter = (): string | undefined => contentFooter;

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Read the 'function' field in the error details to identify which caller passed the bad address
  2. Set Administration -> Email -> From Address to a valid RFC address (name@domain.tld)
  3. In code, default 'from' to the configured setting and run checkAddressFormat before sending

Example fix

// before
const from = Meteor.settings.fromEmail ?? '';
await Mailer.sendMail({ from, subject, body });

// after
const from = Meteor.settings.fromEmail ?? Settings.get('From_Address');
Mailer.checkAddressFormatAndThrow(from, 'myMailer');
await Mailer.sendMail({ from, subject, body });
Defensive patterns

Strategy: validation

Validate before calling

Mailer.checkAddressFormatAndThrow(from, 'myMailerCall');
// reaching here means 'from' is safe; now call send/sendMail

Try / catch

try {
  await Mailer.sendMail({ from, subject, body });
} catch (err) {
  if (err instanceof Meteor.Error && err.error === 'error-invalid-from-address') {
    // err.details.function names the caller; fix the from setting/value
  } else throw err;
}

Prevention

When it happens

Trigger: Mailer.send / sendNoWrap / sendMail invoked with from = 'no-reply' (no domain), an empty string, or a display name without an angle-addr; the SMTP From_Address setting holds an invalid address that flows into these calls.

Common situations: Administration -> Email -> SMTP 'From Address' misconfigured after setup; code reading Meteor.settings.fromEmail that is unset in that environment; setting renamed or reset across version upgrades.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/4b63fde2a4ec5c5d. Report an issue: GitHub.