RocketChat/Rocket.Chat · error · Meteor.Error

error-email-send-failed

error-email-send-failed

Error message

Error trying to send email: ${error.message}

What it means

Thrown from setEmail's internal email-change notification (_sendEmailChangeNotification) when Mailer.send rejects while sending the 'your email address was changed' mail to the old address. The underlying failure (SMTP handshake error, DNS failure, refused connection, invalid From_Email) is embedded in both the interpolated message and details.message. It aborts the setEmail flow even though the address change itself was otherwise valid.

Source

Thrown at apps/meteor/server/lib/users/setEmail.ts:37

	});
});

const _sendEmailChangeNotification = async function (to: string, newEmail: string) {
	const subject = String(settings.get('Email_Changed_Email_Subject'));
	const email = {
		to,
		from: String(settings.get('From_Email')),
		subject,
		html,
		data: {
			email: escapeHTML(newEmail),
		},
	};

	try {
		await Mailer.send(email);
	} catch (error: any) {
		throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${error.message}`, {
			function: 'setEmail',
			message: error.message,
		});
	}
};

export const setEmail = async function (
	userId: string,
	email: string,
	shouldSendVerificationEmail = true,
	verified = false,
	updater?: Updater<IUser>,
	session?: ClientSession,
) {
	email = email.trim();
	if (!userId) {
		throw new Meteor.Error('error-invalid-user', 'Invalid user', { function: '_setEmail' });
	}

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Read the nested error message (details.message) to see the real SMTP error, and check server logs for the Mailer failure.
  2. Verify SMTP settings in Administration > Email > SMTP and send a test email through that screen.
  3. Confirm From_Email is set to an address on a domain your mail provider allows sending from.
  4. Check DNS resolution and outbound connectivity to the SMTP host/port from the Rocket.Chat server itself.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await setEmail(userId, newEmail);
} catch (e: any) {
  if (e.error === 'error-email-send-failed') {
    // e.details.message holds the underlying SMTP error
    logger.error({ msg: 'Email change notification failed', cause: e.details?.message });
    // decide: retry later via a queue, or surface an admin action to fix SMTP
    throw new Meteor.Error('email-change-notification-failed', 'Mail server is not delivering; check SMTP settings');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling setEmail() with a valid new address while SMTP settings are broken: wrong host/port/credentials, empty or placeholder From_Email, server cannot resolve or reach the mail server (outbound 587 blocked), or the provider rejects the message (relay denied, policy rejection).

Common situations: Development environment with no SMTP configured; production after mail-provider credential rotation; From_Email left at a default placeholder domain the provider refuses; firewall/egress rules blocking the SMTP port; the user's old address no longer exists and the server bounces.

Related errors


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