RocketChat/Rocket.Chat · error · Meteor.Error

error-email-send-failed

error-email-send-failed

Error message

Error trying to send email: ${message}

What it means

`sendSMTPTestEmail` wraps `Mailer.send` in try/catch and rethrows any delivery failure as `error-email-send-failed` with `Error trying to send email: <message>`, embedding the underlying error message (typically nodemailer/smtp errors) in both the reason and the details. It sends from `settings.get('From_Email')` to the caller's address, so failures usually mean SMTP configuration or network problems rather than code bugs.

Source

Thrown at apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts:39

			throw new Meteor.Error('error-invalid-user', 'Invalid user', {
				method: 'sendSMTPTestEmail',
			});
		}
		const user = await Meteor.userAsync();
		if (!user?.emails?.[0]?.address) {
			throw new Meteor.Error('error-invalid-email', 'Invalid email', {
				method: 'sendSMTPTestEmail',
			});
		}
		try {
			await Mailer.send({
				to: user.emails[0].address,
				from: settings.get('From_Email'),
				subject: 'SMTP Test Email',
				html: '<p>You have successfully sent an email</p>',
			});
		} catch ({ message }: any) {
			throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${message}`, {
				method: 'sendSMTPTestEmail',
				message,
			});
		}
		return {
			message: 'Sending_your_mail_to_s',
			params: [user.emails[0].address],
		};
	},
});

DDPRateLimiter.addRule(
	{
		type: 'method',
		name: 'sendSMTPTestEmail',
		userId() {
			return true;
		},

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Read the embedded message — nodemailer codes pinpoint the cause (EAUTH/535 = credentials, ETIMEDOUT/ECONNREFUSED = host/port/firewall, ENOTFOUND = DNS, greeting errors = wrong port/TLS mode).
  2. Verify SMTP settings in Admin → Email: SMTP_Host, SMTP_Port, SMTP_Username, SMTP_Password, and the secure/TLS mode matching the port.
  3. Set a valid `From_Email` on a domain your relay is allowed to send from.
  4. Fix configuration, then call `sendSMTPTestEmail` again to confirm delivery end-to-end.
Defensive patterns

Strategy: retry

Validate before calling

// cheap pre-flight: confirm SMTP settings are populated before testing
const smtpReady = (): boolean =>
  Boolean(settings.get('SMTP_Host')) && Boolean(settings.get('From_Email'));

Try / catch

try {
  await Meteor.callAsync('sendSMTPTestEmail');
} catch (e: any) {
  if (e?.error === 'error-email-send-failed') {
    const reason = String(e?.details?.message ?? e?.reason ?? '');
    if (/EAUTH|535/.test(reason)) { /* fix SMTP credentials */ }
    else if (/ETIMEDOUT|ECONNREFUSED/.test(reason)) { /* fix host/port or firewall */ }
    else if (/ENOTFOUND/.test(reason)) { /* fix DNS/host */ }
    // after fixing config, retry sendSMTPTestEmail to confirm
  }
}

Prevention

When it happens

Trigger: Mailer.send throws: wrong SMTP host/port, authentication failure (bad username/password, `EAUTH`, `535`), TLS/STARTTLS mismatch on the port, firewall/DNS blocking outbound SMTP (`ECONNREFUSED`, `ETIMEDOUT`, `ENOTFOUND`), or an invalid/missing `From_Email` rejected by the relay.

Common situations: Initial SMTP setup with wrong credentials; port 465 vs 587 secure-mode confusion; cloud/container environments blocking outbound port 25/587; relay requiring SPF-aligned From address; password changed on the mail provider but not in settings.

Related errors


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