{"record":{"id":"9e65b0fcbc376bfa","repo":"RocketChat/Rocket.Chat","slug":"error-email-send-failed-9e65b0","errorCode":"error-email-send-failed","errorMessage":"Error trying to send email: ${message}","messagePattern":"Error trying to send email: (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts","lineNumber":39,"sourceCode":"\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'sendSMTPTestEmail',\n\t\t\t});\n\t\t}\n\t\tconst user = await Meteor.userAsync();\n\t\tif (!user?.emails?.[0]?.address) {\n\t\t\tthrow new Meteor.Error('error-invalid-email', 'Invalid email', {\n\t\t\t\tmethod: 'sendSMTPTestEmail',\n\t\t\t});\n\t\t}\n\t\ttry {\n\t\t\tawait Mailer.send({\n\t\t\t\tto: user.emails[0].address,\n\t\t\t\tfrom: settings.get('From_Email'),\n\t\t\t\tsubject: 'SMTP Test Email',\n\t\t\t\thtml: '<p>You have successfully sent an email</p>',\n\t\t\t});\n\t\t} catch ({ message }: any) {\n\t\t\tthrow new Meteor.Error('error-email-send-failed', `Error trying to send email: ${message}`, {\n\t\t\t\tmethod: 'sendSMTPTestEmail',\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tmessage: 'Sending_your_mail_to_s',\n\t\t\tparams: [user.emails[0].address],\n\t\t};\n\t},\n});\n\nDDPRateLimiter.addRule(\n\t{\n\t\ttype: 'method',\n\t\tname: 'sendSMTPTestEmail',\n\t\tuserId() {\n\t\t\treturn true;\n\t\t},","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/settings/sendSMTPTestEmail.ts#L21-L57","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Verify SMTP settings in Admin → Email: SMTP_Host, SMTP_Port, SMTP_Username, SMTP_Password, and the secure/TLS mode matching the port.","Set a valid `From_Email` on a domain your relay is allowed to send from.","Fix configuration, then call `sendSMTPTestEmail` again to confirm delivery end-to-end."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// cheap pre-flight: confirm SMTP settings are populated before testing\nconst smtpReady = (): boolean =>\n  Boolean(settings.get('SMTP_Host')) && Boolean(settings.get('From_Email'));","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('sendSMTPTestEmail');\n} catch (e: any) {\n  if (e?.error === 'error-email-send-failed') {\n    const reason = String(e?.details?.message ?? e?.reason ?? '');\n    if (/EAUTH|535/.test(reason)) { /* fix SMTP credentials */ }\n    else if (/ETIMEDOUT|ECONNREFUSED/.test(reason)) { /* fix host/port or firewall */ }\n    else if (/ENOTFOUND/.test(reason)) { /* fix DNS/host */ }\n    // after fixing config, retry sendSMTPTestEmail to confirm\n  }\n}","preventionTips":["Match the SMTP secure/TLS mode to the port (465 = implicit TLS, 587 = STARTTLS).","Keep SMTP credentials and From_Email in sync with the provider; rotate both together.","Confirm outbound SMTP ports are open from the server/container network.","Run sendSMTPTestEmail after every SMTP configuration change."],"tags":["smtp","email","mailer","nodemailer","configuration"],"backgroundTag":"smtp-send-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}