{"record":{"id":"749e93d26d7f628f","repo":"RocketChat/Rocket.Chat","slug":"error-email-send-failed","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/ee/server/lib/deviceManagement/session.ts","lineNumber":113,"sourceCode":"\t\t\t\tmailData.browserInfo = `Rocket.Chat ${app?.name || browser.name} ${app?.bundle || app?.version || browser.version}`;\n\t\t\t\tmailData.osInfo = `${os.name}`;\n\t\t\t\tmailData.deviceInfo = `Desktop App ${cpu.architecture || ''}`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tmailData.userAgent = userAgent || '';\n\t\t\t\tbreak;\n\t\t}\n\n\t\ttry {\n\t\t\tawait Mailer.send({\n\t\t\t\tto: `${name} <${email}>`,\n\t\t\t\tfrom: Accounts.emailTemplates.from,\n\t\t\t\tsubject: settings.get('Device_Management_Email_Subject'),\n\t\t\t\thtml: mailTemplates,\n\t\t\t\tdata: mailData,\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: 'listenSessionLogin',\n\t\t\t\tmessage,\n\t\t\t});\n\t\t}\n\t});\n};\n","sourceCodeStart":95,"sourceCodeEnd":120,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/lib/deviceManagement/session.ts#L95-L120","documentation":"Thrown by listenSessionLogin (deviceManagement/session.ts) when Mailer.send rejects while sending the device-management session-login notification email. The original error is caught by destructuring { message } and re-thrown as a Meteor.Error code 'error-email-send-failed' wrapping the underlying message. The original cause lives in the error.details.message field.","triggerScenarios":"A session-login event fires (new device/browser login) and Mailer.send fails: SMTP host unreachable, auth rejected, invalid recipient address, From address misconfigured, or the email template / Device_Management_Email_Subject setting is empty.","commonSituations":"SMTP credentials rotated but not updated; From address rejected by relay; user's email field invalid; email gateway down or rate-limiting; missing Mailer configuration on a fresh install.","solutions":["Read error.details.message for the SMTP/transport cause and fix the specific failure (credentials, host, port, TLS).","Verify Accounts.emailTemplates.from and the SMTP settings are valid and that the relay accepts the From address.","Confirm the target user has a valid email and that Device_Management_Email_Subject is set.","Retry the login/notification once the transport is healthy — the underlying login itself is not affected."],"exampleFix":"// before\n} catch ({ message }: any) {\n  throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${message}`);\n}\n\n// caller-side: don't let a notification failure break login\ntry { await sendSessionLoginMail(...); }\ncatch (e) { logger.error({ msg: 'session email failed', cause: e.details?.message }); }","handlingStrategy":"try-catch","validationCode":"async function smtpReachable(): Promise<boolean> {\n  // ping the configured SMTP host/port before relying on Mailer\n  return new Promise((resolve) => {\n    const socket = net.connect(Number(smtpPort), smtpHost);\n    socket.setTimeout(2000).on('connect', () => { socket.end(); resolve(true); }).on('error', () => resolve(false)).on('timeout', () => { socket.destroy(); resolve(false); });\n  });\n}","typeGuard":"null","tryCatchPattern":"try { await sendSessionLoginMail(...); } catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-email-send-failed') {\n    logger.error({ msg: 'session email failed', cause: e.details?.message }); // don't break login\n  } else throw e;\n}","preventionTips":["Validate SMTP settings and From address on save.","Keep device-management notification non-blocking so login UX is unaffected.","Surface error.details.message in admin alerts for actionable SMTP diagnostics."],"tags":["email","device-management","smtp","enterprise"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}