{"record":{"id":"35273748e096cd93","repo":"plandex-ai/plandex","slug":"error-sending-verification-email","errorCode":null,"errorMessage":"Error sending verification email: ","messagePattern":"Error sending verification email: ","errorType":"http","errorClass":"http","httpStatus":500,"severity":"error","filePath":"app/server/handlers/sessions.go","lineNumber":111,"sourceCode":"\n\t\t// get sha256 hash of pin\n\t\thashBytes := sha256.Sum256(pinBytes)\n\t\tpinHash := hex.EncodeToString(hashBytes[:])\n\n\t\t// create verification\n\t\terr = db.CreateEmailVerification(req.Email, req.UserId, pinHash)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error creating email verification: %v\\n\", err)\n\t\t\thttp.Error(w, \"Error creating email verification: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\terr = email.SendVerificationEmail(req.Email, string(pinBytes))\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error sending verification email: %v\\n\", err)\n\t\t\thttp.Error(w, \"Error sending verification email: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tres = shared.CreateEmailVerificationResponse{\n\t\t\tHasAccount: hasAccount,\n\t\t}\n\t} else {\n\t\tres = shared.CreateEmailVerificationResponse{\n\t\t\tHasAccount:  hasAccount,\n\t\t\tIsLocalMode: true,\n\t\t}\n\t}\n\n\tbytes, err := json.Marshal(res)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling response: %v\\n\", err)\n\t\thttp.Error(w, \"Error marshalling response: \"+err.Error(), http.StatusInternalServerError)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/sessions.go#L93-L129","documentation":"This error is returned when email.SendVerificationEmail fails after the verification record was successfully created. The handler responds with HTTP 500 prefixed 'Error sending verification email: '. It wraps whatever SMTP/mail-provider error occurred, so the PIN exists in the DB but was never delivered to the user.","triggerScenarios":"POST to the email-verification endpoint (non-development, non-LOCAL_MODE environment) where the SMTP connection fails: bad SMTP host/port, auth rejection, TLS failure, provider rate limit, or timeout while sending to req.Email.","commonSituations":"Missing or wrong SMTP_* environment variables (host, port, user, password); firewall blocking outbound port 587/465; mail provider credentials expired or rotated; sending from an unverified domain causing provider rejection; no network access in a container.","solutions":["Read the wrapped error in the server log to see the exact SMTP/provider failure","Verify SMTP environment variables (host, port, credentials, from-address) are set correctly","Test outbound connectivity to the SMTP host/port from the server (telnet/nc)","Confirm the mail provider account is active and the sender domain is verified","Retry the verification request after fixing mail config"],"exampleFix":"// before: mail config only checked at send time\nerr = email.SendVerificationEmail(req.Email, string(pinBytes))\n// after: fail fast at startup with a config check\nfunc init() {\n\tfor _, k := range []string{\"SMTP_HOST\", \"SMTP_PORT\", \"SMTP_USER\", \"SMTP_PASS\"} {\n\t\tif os.Getenv(k) == \"\" {\n\t\t\tlog.Fatalf(\"missing required env var %s\", k)\n\t\t}\n\t}\n}","handlingStrategy":"fallback","validationCode":"// preflight SMTP config before triggering verification\nhost := os.Getenv(\"SMTP_HOST\")\nport := os.Getenv(\"SMTP_PORT\")\nconn, err := net.DialTimeout(\"tcp\", net.JoinHostPort(host, port), 5*time.Second)\nif err != nil {\n\treturn fmt.Errorf(\"SMTP unreachable: %w\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"// treat 500 on verification as a mail-config problem; surface it and offer resend\nif resp.StatusCode == http.StatusInternalServerError {\n\tvar msg string\n\tjson.NewDecoder(resp.Body).Decode(&msg)\n\tif strings.HasPrefix(msg, \"Error sending verification email\") {\n\t\treturn fmt.Errorf(\"mail delivery failed, check SMTP config; PIN not delivered\")\n\t}\n}","preventionTips":["Validate SMTP_* env vars at service startup","Test outbound SMTP connectivity in CI/staging","Verify sender domain with your email provider","Implement an async resend mechanism for failed verification emails"],"tags":["email","smtp","http-500","go"],"backgroundTag":"smtp-send-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}