{"record":{"id":"8ce329b45b34e9fb","repo":"Billionmail/BillionMail","slug":"smtp-password-is-required","errorCode":null,"errorMessage":"SMTP password is required","messagePattern":"SMTP password is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go","lineNumber":84,"sourceCode":"func validateAlertSettings(settings *v1.SetBlacklistAlertSettingsReq) error {\n\tif settings.SenderEmail == \"\" {\n\t\treturn fmt.Errorf(\"sender email is required\")\n\t}\n\n\tif !strings.Contains(settings.SenderEmail, \"@\") {\n\t\treturn fmt.Errorf(\"invalid sender email format\")\n\t}\n\n\tif settings.SMTPServer == \"\" {\n\t\treturn fmt.Errorf(\"SMTP server is required\")\n\t}\n\n\tif settings.SMTPPort < 1 || settings.SMTPPort > 65535 {\n\t\treturn fmt.Errorf(\"SMTP port must be between 1 and 65535\")\n\t}\n\n\tif settings.SMTPPassword == \"\" {\n\t\treturn fmt.Errorf(\"SMTP password is required\")\n\t}\n\n\tif len(settings.RecipientList) == 0 {\n\t\treturn fmt.Errorf(\"at least one recipient is required\")\n\t}\n\n\tfor _, recipient := range settings.RecipientList {\n\t\tif !strings.Contains(recipient, \"@\") {\n\t\t\treturn fmt.Errorf(\"invalid recipient email format: %s\", recipient)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc testSMTPConnectionWithRelay(ctx context.Context, settings *v1.SetBlacklistAlertSettingsReq) error {\n\t//g.Log().Infof(ctx, \"Testing SMTP connection to %s:%d\", settings.SMTPServer, settings.SMTPPort)\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go#L66-L102","documentation":"validateAlertSettings requires a non-empty SMTPPassword for blacklist alert email delivery. The password is used to authenticate against the SMTP server when the test email is sent; an empty string is treated as missing credentials.","triggerScenarios":"Calling SetBlacklistAlertSettings with SMTPPassword empty or omitted in the request payload.","commonSituations":"Frontend form does not bind the password field; secret stripped by an env templating step that left it blank; admin assumes the mail service relay needs no password but this code path requires one.","solutions":["Provide the SMTP account password in the smtpPassword field of the request.","Check that secret injection (env var / template) actually populated the field before submission.","If using a local relay that needs no auth, set a placeholder or extend the validator to skip the check when SMTPServer points at the internal mail service."],"exampleFix":"// before\nsettings.SMTPPassword = os.Getenv(\"SMTP_PASSWORD\") // empty if unset\n// after\npwd := os.Getenv(\"SMTP_PASSWORD\")\nif pwd == \"\" { return errors.New(\"SMTP_PASSWORD env var not set\") }\nsettings.SMTPPassword = pwd","handlingStrategy":"validation","validationCode":"if (!payload.smtpPassword || payload.smtpPassword.trim() === '') {\n  throw new Error('smtpPassword is required before saving alert settings')\n}","typeGuard":"function hasPassword(s: { smtpPassword?: string }): s is { smtpPassword: string } {\n  return typeof s.smtpPassword === 'string' && s.smtpPassword.length > 0\n}","tryCatchPattern":"try {\n  await api.setBlacklistAlertSettings(payload)\n} catch (e) {\n  if (String(e).includes('SMTP password is required')) {\n    showFormError('passwordField', 'SMTP password is required')\n  }\n}","preventionTips":["Bind the password field in the frontend form and block submission while empty","Verify secret injection (env/template) actually populated the value","Treat credentials as required fields in form-level validation before the API call"],"tags":["validation","smtp","auth","config"],"backgroundTag":"missing-smtp-credentials","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}