{"record":{"id":"afc58f1182643a67","repo":"RocketChat/Rocket.Chat","slug":"error-email-send-failed-afc58f","errorCode":"error-email-send-failed","errorMessage":"Error trying to send email: ${error.message}","messagePattern":"Error trying to send email: (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/users/setEmail.ts","lineNumber":37,"sourceCode":"\t});\n});\n\nconst _sendEmailChangeNotification = async function (to: string, newEmail: string) {\n\tconst subject = String(settings.get('Email_Changed_Email_Subject'));\n\tconst email = {\n\t\tto,\n\t\tfrom: String(settings.get('From_Email')),\n\t\tsubject,\n\t\thtml,\n\t\tdata: {\n\t\t\temail: escapeHTML(newEmail),\n\t\t},\n\t};\n\n\ttry {\n\t\tawait Mailer.send(email);\n\t} catch (error: any) {\n\t\tthrow new Meteor.Error('error-email-send-failed', `Error trying to send email: ${error.message}`, {\n\t\t\tfunction: 'setEmail',\n\t\t\tmessage: error.message,\n\t\t});\n\t}\n};\n\nexport const setEmail = async function (\n\tuserId: string,\n\temail: string,\n\tshouldSendVerificationEmail = true,\n\tverified = false,\n\tupdater?: Updater<IUser>,\n\tsession?: ClientSession,\n) {\n\temail = email.trim();\n\tif (!userId) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { function: '_setEmail' });\n\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/users/setEmail.ts#L19-L55","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the nested error message (details.message) to see the real SMTP error, and check server logs for the Mailer failure.","Verify SMTP settings in Administration > Email > SMTP and send a test email through that screen.","Confirm From_Email is set to an address on a domain your mail provider allows sending from.","Check DNS resolution and outbound connectivity to the SMTP host/port from the Rocket.Chat server itself."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await setEmail(userId, newEmail);\n} catch (e: any) {\n  if (e.error === 'error-email-send-failed') {\n    // e.details.message holds the underlying SMTP error\n    logger.error({ msg: 'Email change notification failed', cause: e.details?.message });\n    // decide: retry later via a queue, or surface an admin action to fix SMTP\n    throw new Meteor.Error('email-change-notification-failed', 'Mail server is not delivering; check SMTP settings');\n  }\n  throw e;\n}","preventionTips":["Send a test email from Administration > Email after every SMTP configuration change.","Monitor mail delivery/queue health so broken SMTP is detected before users hit email-changing flows.","Keep From_Email on a domain your provider is authorized to send from.","Distinguish permanent config errors (auth rejected, relay denied) from transient ones (timeouts) before retrying."],"tags":["email","smtp","mailer","network"],"backgroundTag":"smtp-send-failure","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}