{"record":{"id":"66f586f1eb20981a","repo":"hcengineering/platform","slug":"please-specify-ses-or-smtp-configuration","errorCode":null,"errorMessage":"Please specify SES or SMTP configuration","messagePattern":"Please specify SES or SMTP configuration","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/mail/pod-mail/src/config.ts","lineNumber":157,"sourceCode":"    Password: password,\n    TlsMode: tlsMode ?? TlsOptions.UPGRADE,\n    DebugLog: debugLog,\n    AllowSelfSigned: allowSelfSigned\n  }\n}\n\nconst config: Config = (() => {\n  const port = parseNumber(process.env[envMap.Port])\n  if (port === undefined) {\n    throw Error('Missing env variable: Port')\n  }\n  const isSmtpConfig = !isEmpty(process.env[envMap.SmtpHost])\n  const isSesConfig = !isEmpty(process.env[envMap.SesAccessKey])\n  if (isSmtpConfig && isSesConfig) {\n    throw Error('Both SMTP and SES configuration are specified, please specify only one')\n  }\n  if (!isSmtpConfig && !isSesConfig) {\n    throw Error('Please specify SES or SMTP configuration')\n  }\n  const params: Config = {\n    port,\n    source: process.env[envMap.Source],\n    replyTo: process.env[envMap.ReplyTo],\n    sesConfig: isSesConfig ? buildSesConfig() : undefined,\n    smtpConfig: isSmtpConfig ? buildSmtpConfig() : undefined\n  }\n\n  return params\n})()\n\nexport default config\n","sourceCodeStart":139,"sourceCodeEnd":171,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/mail/pod-mail/src/config.ts#L139-L171","documentation":"pod-mail requires at least one mail backend configuration. If neither SMTP_HOST nor SES_ACCESS_KEY is present (non-empty) in the environment, the config IIFE throws 'Please specify SES or SMTP configuration' at startup.","triggerScenarios":"Starting pod-mail with Port set but with neither SMTP_HOST nor SES_ACCESS_KEY defined — the mail sender has no delivery backend.","commonSituations":"Fresh deployment with only infrastructure env vars; accidentally clearing mail variables during a secret rotation; running the image without mounting the env file that carries SMTP/SES settings.","solutions":["Configure exactly one backend: set SMTP_HOST/SMTP_PORT (plus credentials) or SES_ACCESS_KEY/SES_SECRET_KEY/SES_REGION.","Verify the secret/env file containing mail settings is actually mounted and loaded.","Check variable-name typos — the service only looks at the envMap keys (e.g. SMTP_HOST, SES_ACCESS_KEY)."],"exampleFix":"// before\nPORT=4001\n# no mail backend configured\n// after\nPORT=4001\nSMTP_HOST=smtp.example.com\nSMTP_PORT=587\nSMTP_USERNAME=user\nSMTP_PASSWORD=pass","handlingStrategy":"validation","validationCode":"const smtp = !!process.env.SMTP_HOST;\nconst ses = !!process.env.SES_ACCESS_KEY;\nif (!smtp && !ses) {\n  throw new Error('No mail backend configured: set SMTP_HOST/SMTP_PORT or SES_ACCESS_KEY/SES_SECRET_KEY/SES_REGION');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await import('./config');\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Please specify SES or SMTP')) {\n    console.error('No mail backend: configure SMTP or SES env vars for pod-mail');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Include mail backend vars in the service's base deployment template so fresh deploys never start empty.","Mount the env secret containing SMTP/SES settings and verify it in the pod spec.","Check for variable-name typos against envMap in pod-mail/src/config.ts.","Smoke-test config loading in CI with the production env template."],"tags":["env","configuration","smtp","ses","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}