{"record":{"id":"78e5866b492625c3","repo":"appsmithorg/appsmith","slug":"mail-not-sent-appsmith-mail-enabled-env-val-is-di","errorCode":null,"errorMessage":"Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, please refer to https://docs.appsmith.com/setup/instance-configuration/email to enable it.","messagePattern":"Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, please refer to https://docs\\.appsmith\\.com/setup/instance-configuration/email to enable it\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"app/client/packages/rts/src/ctl/mailer.ts","lineNumber":33,"sourceCode":"  console.log(\"Sending Error mail to admins.\");\n  try {\n    if (\n      !mailEnabled ||\n      !mailFrom ||\n      !mailHost ||\n      !mailPort ||\n      !mailUser ||\n      !mailPass\n    ) {\n      throw new Error(\n        \"Failed to send error mail. Email provider is not configured, please refer to https://docs.appsmith.com/setup/instance-configuration/email to configure it.\",\n      );\n    } else if (!mailTo) {\n      throw new Error(\n        \"Failed to send error mail. Admin email(s) not configured, please refer to https://docs.appsmith.com/setup/instance-configuration/disable-user-signup#administrator-emails to configure it.\",\n      );\n    } else if (!mailEnabled) {\n      throw new Error(\n        \"Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, please refer to https://docs.appsmith.com/setup/instance-configuration/email to enable it.\",\n      );\n    } else {\n      const backupFiles = await utils.listLocalBackupFiles();\n      const lastBackupfile = backupFiles.pop();\n      const lastBackupTimestamp = lastBackupfile.match(\n        /appsmith-backup-(.*)\\.tar.gz/,\n      )[1];\n      const lastBackupPath = Constants.BACKUP_PATH + \"/\" + lastBackupfile;\n\n      const domainName = process.env.APPSMITH_CUSTOM_DOMAIN;\n      const instanceName = process.env.APPSMITH_INSTANCE_NAME;\n\n      let text =\n        \"Appsmith backup did not complete successfully.\\n\\n \" +\n        \"Backup timestamp: \" +\n        backupTimestamp +\n        \"\\n\\n\" +","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/packages/rts/src/ctl/mailer.ts#L15-L51","documentation":"Intended to fire when mail is disabled. IMPORTANT DEFECT grounded in the source: this is the THIRD branch ('else if (!mailEnabled)'), but the FIRST branch already throws when !mailEnabled is true (it is the first operand of the first if). Therefore mailEnabled can never be falsy by the time this branch is evaluated — this error is UNREACHABLE DEAD CODE. The condition the message describes is actually caught by error [13]'s branch, so a disabled APPSMITH_MAIL_ENABLED in practice yields the 'Email provider is not configured' message instead.","triggerScenarios":"None at runtime as written — the branch is unreachable because the first if catches !mailEnabled. A developer reading the source might expect APPSMITH_MAIL_ENABLED=false to land here, but it does not.","commonSituations":"Developer sees this message in the source and searches for it as a user-facing error; in practice they will hit error [13] instead. The dead branch is a code-smell to flag.","solutions":["Recognize that a disabled APPSMITH_MAIL_ENABLED actually triggers error [13]; fix the real config there.","Refactor the mailer so the disabled-check is its own first branch, distinct from the missing-credentials check, so each message is reachable and accurate.","Add a unit test per branch to surface the dead path.","If you genuinely want this distinct message to be reachable, reorder: check mailEnabled alone first, then the credential tuple."],"exampleFix":"// before (unreachable third branch)\nif (!mailEnabled || !mailFrom || ...) { throw providerNotConfigured; }\nelse if (!mailTo) { throw adminNotConfigured; }\nelse if (!mailEnabled) { throw mailDisabled; }  // dead\n\n// after (each message reachable)\nif (!mailEnabled) { throw mailDisabled; }\nelse if (!mailFrom || !mailHost || !mailPort || !mailUser || !mailPass) { throw providerNotConfigured; }\nelse if (!mailTo) { throw adminNotConfigured; }","handlingStrategy":"validation","validationCode":"// As written this branch is unreachable; the disabled case is caught by [13].\n// After refactor, validate distinctly:\nif (process.env.APPSMITH_MAIL_ENABLED === 'false') throw new Error('Re-enable APPSMITH_MAIL_ENABLED to send mail.');","typeGuard":"const isMailEnabled = (env: NodeJS.ProcessEnv): boolean => env.APPSMITH_MAIL_ENABLED === 'true';","tryCatchPattern":null,"preventionTips":["Refactor the if-chain so the disabled-check is first and distinct from missing-credentials.","Add per-branch unit tests to surface dead paths.","Map each config gap to one reachable, accurate message."],"tags":["email","smtp","configuration","dead-code","operations"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}