{"record":{"id":"d7de775e86c913a6","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-email-address","errorCode":"error-invalid-email-address","errorMessage":"error-invalid-email-address","messagePattern":"error-invalid-email-address","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/messages.ts","lineNumber":66,"sourceCode":"\t\t\t<p><strong>Visitor email:</strong> ${email}</p>\n\t\t\t<p><strong>Message:</strong><br>${emailMessage}</p>`);\n\n\tconst fromEmail = settings.get<string>('From_Email').match(/\\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,4}\\b/i);\n\n\tlet from: string;\n\tif (fromEmail) {\n\t\tfrom = fromEmail[0];\n\t} else {\n\t\tfrom = settings.get<string>('From_Email');\n\t}\n\n\tif (settings.get('Livechat_validate_offline_email')) {\n\t\tconst emailDomain = email.substr(email.lastIndexOf('@') + 1);\n\n\t\ttry {\n\t\t\tawait dnsResolveMx(emailDomain);\n\t\t} catch (e) {\n\t\t\tthrow new Meteor.Error('error-invalid-email-address');\n\t\t}\n\t}\n\n\t// TODO Block offline form if Livechat_offline_email is undefined\n\t// (it does not make sense to have an offline form that does nothing)\n\t// `this.sendEmail` will throw an error if the email is invalid\n\t// thus this breaks livechat, since the \"to\" email is invalid, and that returns an [invalid email] error to the livechat client\n\tlet emailTo = settings.get<string>('Livechat_offline_email');\n\tif (department && department !== '') {\n\t\tconst dep = await LivechatDepartment.findOneByIdOrName(department, { projection: { email: 1 } });\n\t\tif (dep) {\n\t\t\temailTo = dep.email || emailTo;\n\t\t}\n\t}\n\n\tconst fromText = `${name} - ${email} <${from}>`;\n\tconst replyTo = `${name} <${email}>`;\n\tconst subject = `Livechat offline message from ${name}: ${`${emailMessage}`.substring(0, 20)}`;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/messages.ts#L48-L84","documentation":"Thrown by `sendOfflineMessage` when `Livechat_validate_offline_email` is enabled and `dns.resolveMx()` on the domain part of the submitted email (after the last '@') rejects. The intent is blocking fake addresses; in practice any MX-resolution failure throws — invalid domain, no MX records, or the server cannot reach DNS at all.","triggerScenarios":"Visitor submits an email whose domain has no MX records (typos like 'user@gmial.com' or disposable domains), or the Rocket.Chat server's DNS/resolver is broken/firewalled, with Livechat_validate_offline_email turned on.","commonSituations":"Enabling email validation to fight spam and then legitimate domains without MX (rare but legal) or corporate DNS blocks get rejected; containerized deployments with no working DNS; transient resolver outages turning valid submissions into errors.","solutions":["Verify the domain actually has MX records (`dig MX example.com`) and ask the user to fix typos","If false positives from DNS/network issues outweigh the benefit, disable the `Livechat_validate_offline_email` setting","Fix the server's DNS resolution (containers: --dns, resolv.conf) so resolveMx works reliably"],"exampleFix":"// before\nawait sendOfflineMessage({ message, name, email: 'a@gmial.com' });\n\n// after\n// client-side soft check to catch typos before the strict server check\nconst [, domain] = email.split('@');\nif (!domain || !/^[a-z0-9.-]+\\.[a-z]{2,}$/i.test(domain)) {\n  throw new Error('Check the email domain');\n}\nawait sendOfflineMessage({ message, name, email });","handlingStrategy":"try-catch","validationCode":"const [, domain] = email.split('@');\nif (!domain || !/^[a-z0-9.-]+\\.[a-z]{2,}$/i.test(domain)) {\n  throw new Error('Email domain looks malformed');\n}\n// full MX check is server-side and can fail on network issues — catch there","typeGuard":"const hasPlausibleEmailDomain = (email: string): boolean =>\n  /^[^@\\s]+@([a-z0-9-]+\\.)+[a-z]{2,}$/i.test(email);","tryCatchPattern":"try {\n  await sendOfflineMessage(data);\n} catch (e) {\n  if (isMeteorError(e, 'error-invalid-email-address')) {\n    // ask the user to re-check the address; do NOT auto-retry (DNS may be fine and the domain fake)\n  }\n}","preventionTips":["Prefer disabling Livechat_validate_offline_email when server DNS is unreliable","Keep server DNS resolvers healthy in containerized deployments","Catch and humanize this error; raw rejection looks like a server bug to visitors"],"tags":["omnichannel","offline-form","email","dns","mx","network"],"backgroundTag":"email-domain-verification-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}