appsmithorg/appsmith · warning · Error
Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, pl
Error message
Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, please refer to https://docs.appsmith.com/setup/instance-configuration/email to enable it.
What it means
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.
Source
Thrown at app/client/packages/rts/src/ctl/mailer.ts:33
console.log("Sending Error mail to admins.");
try {
if (
!mailEnabled ||
!mailFrom ||
!mailHost ||
!mailPort ||
!mailUser ||
!mailPass
) {
throw new Error(
"Failed to send error mail. Email provider is not configured, please refer to https://docs.appsmith.com/setup/instance-configuration/email to configure it.",
);
} else if (!mailTo) {
throw new Error(
"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.",
);
} else if (!mailEnabled) {
throw new Error(
"Mail not sent! APPSMITH_MAIL_ENABLED env val is disabled, please refer to https://docs.appsmith.com/setup/instance-configuration/email to enable it.",
);
} else {
const backupFiles = await utils.listLocalBackupFiles();
const lastBackupfile = backupFiles.pop();
const lastBackupTimestamp = lastBackupfile.match(
/appsmith-backup-(.*)\.tar.gz/,
)[1];
const lastBackupPath = Constants.BACKUP_PATH + "/" + lastBackupfile;
const domainName = process.env.APPSMITH_CUSTOM_DOMAIN;
const instanceName = process.env.APPSMITH_INSTANCE_NAME;
let text =
"Appsmith backup did not complete successfully.\n\n " +
"Backup timestamp: " +
backupTimestamp +
"\n\n" +View on GitHub (pinned to 8cd9021c24)
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.
Example fix
// before (unreachable third branch)
if (!mailEnabled || !mailFrom || ...) { throw providerNotConfigured; }
else if (!mailTo) { throw adminNotConfigured; }
else if (!mailEnabled) { throw mailDisabled; } // dead
// after (each message reachable)
if (!mailEnabled) { throw mailDisabled; }
else if (!mailFrom || !mailHost || !mailPort || !mailUser || !mailPass) { throw providerNotConfigured; }
else if (!mailTo) { throw adminNotConfigured; } Defensive patterns
Strategy: validation
Validate before calling
// As written this branch is unreachable; the disabled case is caught by [13].
// After refactor, validate distinctly:
if (process.env.APPSMITH_MAIL_ENABLED === 'false') throw new Error('Re-enable APPSMITH_MAIL_ENABLED to send mail.'); Type guard
const isMailEnabled = (env: NodeJS.ProcessEnv): boolean => env.APPSMITH_MAIL_ENABLED === 'true';
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to send error mail. Email provider is not configured,
- Failed to send error mail. Admin email(s) not configured, pl
- Database URL not found. Please check APPSMITH_DB_URL or APPS
- Redis URL not found. Please check APPSMITH_REDIS_URL configu
- The NODE_ENV environment variable is required but was not sp
AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12).
Data as JSON: /api/errors/78e5866b492625c3.
Report an issue: GitHub.