{"record":{"id":"d2403dacc3466da9","repo":"appwrite/appwrite","slug":"user-email-not-found-could-be","errorCode":"USER_EMAIL_NOT_FOUND","errorMessage":"User email could not be found.","messagePattern":"User email could not be found\\.","errorType":"exception","errorClass":"Appwrite\\Extend\\Exception","httpStatus":400,"severity":"error","filePath":"app/controllers/api/account.php","lineNumber":5596,"sourceCode":"    ->param('phrase', false, new Boolean(), 'Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.', true)\n    ->inject('request')\n    ->inject('response')\n    ->inject('project')\n    ->inject('platform')\n    ->inject('user')\n    ->inject('dbForProject')\n    ->inject('locale')\n    ->inject('queueForEvents')\n    ->inject('publisherForMails')\n    ->inject('proofForCode')\n    ->inject('authorization')\n    ->action(function (bool $phrase, Request $request, Response $response, Document $project, array $platform, User $user, Database $dbForProject, Locale $locale, Event $queueForEvents, MailPublisher $publisherForMails, ProofsCode $proofForCode, Authorization $authorization) {\n        if (empty(System::getEnv('_APP_SMTP_HOST'))) {\n            throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');\n        }\n\n        if (empty($user->getAttribute('email'))) {\n            throw new Exception(Exception::USER_EMAIL_NOT_FOUND);\n        }\n\n        if ($user->getAttribute('emailVerification')) {\n            throw new Exception(Exception::USER_EMAIL_ALREADY_VERIFIED);\n        }\n\n        if ($phrase === true) {\n            $phrase = (new Phrase())->generate();\n        }\n\n        $secret = $proofForCode->generate();\n        $expire = DateTime::formatTz(DateTime::addSeconds(new \\DateTime(), TOKEN_EXPIRATION_OTP));\n\n        $verification = new Document([\n            '$id' => ID::unique(),\n            'userId' => $user->getId(),\n            'userInternalId' => $user->getSequence(),\n            'type' => TOKEN_TYPE_VERIFICATION_OTP,","sourceCodeStart":5578,"sourceCodeEnd":5614,"githubUrl":"https://github.com/appwrite/appwrite/blob/7eab5f1970bacb06f8cce069c27b7d14a4178153/app/controllers/api/account.php#L5578-L5614","documentation":"Thrown when an email-verification endpoint is called for a user account that has no email attribute set. After the SMTP check, Appwrite verifies the current user actually has an email to send the verification message to; otherwise it fails with this error.","triggerScenarios":"POST /v1/account/verification for an account created via phone, OAuth, or anonymous sessions where `user.email` is empty.","commonSituations":"Anonymous-session users later trying to verify an email they never added; phone-signup users attempting email verification; flows assuming every user has an email.","solutions":["Add an email to the account first (updateEmail or adding email credentials) before requesting verification.","Check `user.email` client-side and route users without an email to an add-email flow instead of the verification endpoint.","If the account is anonymous, convert it to a permanent account with email/password first."],"exampleFix":"// before\nawait account.createVerification('https://app.example.com/verify'); // user has no email\n// after\nconst user = await account.get();\nif (!user.email) {\n  await account.updateEmail('user@example.com', password);\n}\nawait account.createVerification('https://app.example.com/verify');","handlingStrategy":"type-guard","validationCode":"const user = await account.get();\nif (!user.email) {\n  // route to add-email flow before requesting verification\n}","typeGuard":"function hasEmail(user) {\n  return typeof user?.email === 'string' && user.email.length > 0;\n}","tryCatchPattern":"try {\n  await account.createVerification(redirectUrl);\n} catch (e) {\n  if (e.type === 'user_email_not_found') {\n    redirectTo('add-email');\n  }\n}","preventionTips":["Check the user object for an email attribute before calling verification endpoints.","Handle anonymous and phone-only accounts with explicit add-email flows.","Never assume every authenticated user has an email address."],"tags":["email-verification","user-not-found","account"],"backgroundTag":"user-not-found","analyzedSha":"7eab5f1970bacb06f8cce069c27b7d14a4178153","analyzedAt":"2026-09-16T21:43:23.363Z","contentChangedAt":"2026-09-16T21:43:23.363Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}