{"record":{"id":"9855b78c67392d48","repo":"RocketChat/Rocket.Chat","slug":"error-email-send-failed-9855b7","errorCode":"error-email-send-failed","errorMessage":"Error trying to send email: ${errorMessage}","messagePattern":"Error trying to send email: (.+?)","errorType":"exception","errorClass":"MeteorError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/users/saveUser/sendUserEmail.ts","lineNumber":42,"sourceCode":"\n\tconst email = {\n\t\tto: userData.email,\n\t\tfrom: settings.get<string>('From_Email'),\n\t\tsubject,\n\t\thtml,\n\t\tdata: {\n\t\t\temail: userData.email,\n\t\t\tpassword: userData.password ?? '******',\n\t\t\t...(typeof userData.name !== 'undefined' ? { name: userData.name } : {}),\n\t\t},\n\t};\n\n\ttry {\n\t\tawait Mailer.send(email);\n\t} catch (error) {\n\t\tconst errorMessage = typeof error === 'object' && error && 'message' in error ? error.message : '';\n\n\t\tthrow new MeteorError('error-email-send-failed', `Error trying to send email: ${errorMessage}`, {\n\t\t\tfunction: 'RocketChat.saveUser',\n\t\t\tmessage: errorMessage,\n\t\t});\n\t}\n}\n\nexport async function sendWelcomeEmail(userData: Pick<SaveUserData, 'email' | 'name' | 'password'>) {\n\treturn sendUserEmail(settings.get('Accounts_UserAddedEmail_Subject'), html, userData);\n}\n\nexport async function sendPasswordEmail(userData: Pick<SaveUserData, 'email' | 'name' | 'password'>) {\n\treturn sendUserEmail(settings.get('Password_Changed_Email_Subject'), passwordChangedHtml, userData);\n}\n","sourceCodeStart":24,"sourceCodeEnd":56,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/users/saveUser/sendUserEmail.ts#L24-L56","documentation":"sendUserEmail wraps Mailer.send failures as error-email-send-failed (MeteorError, function 'RocketChat.saveUser'), embedding the transport's message in both the error text and the details. It fires while sending the welcome or password email during user creation/save, so a broken SMTP setup can abort the whole save.","triggerScenarios":"Creating a user (saveUser with sendPassword/welcome email enabled) when SMTP settings are missing or wrong: no host configured, authentication rejected, TLS handshake failure, DNS resolution failure, or the provider rejecting the sender address.","commonSituations":"Fresh installs that never configured SMTP; credentials rotated or app passwords revoked (Gmail); From address not verified with the provider; firewall/DNS blocking outbound mail in containers.","solutions":["Verify SMTP settings under Administration > Settings > Email and use the 'send test email' action to reproduce","Read the embedded errorMessage — 'self signed certificate' means enable trustTLS/ignoreTLS, 'Invalid login' means wrong credentials, 'getaddrinfo' means wrong host/DNS","If email delivery must not block user creation, decouple it: catch or queue the email instead of letting it abort saveUser"],"exampleFix":"// before\nawait sendUserEmail(subject, html, userData); // SMTP down -> whole save fails\n\n// after\ntry {\n  await sendUserEmail(subject, html, userData);\n} catch (e) {\n  logger.error({ msg: 'welcome email failed', user: userData.email, reason: e.details?.message });\n  // user creation proceeds; email is retried/queued by your own logic\n}","handlingStrategy":"try-catch","validationCode":"// smoke-test SMTP before enabling email-bearing user creation flows\n// (Administration > Settings > Email > 'Send a test mail' exercises Mailer.send directly)","typeGuard":"const isEmailSendFailure = (e: unknown): e is { error: string; details?: { message?: string } } =>\\n  typeof e === 'object' && e !== null && (e as { error?: unknown }).error === 'error-email-send-failed';","tryCatchPattern":"try {\n  await sendUserEmail(subject, html, userData);\n} catch (e) {\n  if (isEmailSendFailure(e)) {\n    logger.error({ msg: 'email send failed', reason: e.details?.message });\n    queueForRetry(userData); // delivery failure must not abort user creation\n  }\n}","preventionTips":["Verify SMTP with a test email whenever mail settings or credentials change","Read the embedded transport message: it distinguishes auth, TLS, and DNS failures","Keep transactional email out of the critical path of user creation"],"tags":["email","smtp","mailer","users","configuration"],"backgroundTag":"smtp-send-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}