appwrite/appwrite · error · Appwrite\Extend\Exception

USER_EMAIL_NOT_FOUND

USER_EMAIL_NOT_FOUND

Error message

User email could not be found.

What it means

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.

Solutions

  1. Add an email to the account first (updateEmail or adding email credentials) before requesting verification.
  2. Check `user.email` client-side and route users without an email to an add-email flow instead of the verification endpoint.
  3. If the account is anonymous, convert it to a permanent account with email/password first.

Example fix

// before
await account.createVerification('https://app.example.com/verify'); // user has no email
// after
const user = await account.get();
if (!user.email) {
  await account.updateEmail('user@example.com', password);
}
await account.createVerification('https://app.example.com/verify');
Defensive patterns

Strategy: type-guard

Validate before calling

const user = await account.get();
if (!user.email) {
  // route to add-email flow before requesting verification
}

Type guard

function hasEmail(user) {
  return typeof user?.email === 'string' && user.email.length > 0;
}

Try / catch

try {
  await account.createVerification(redirectUrl);
} catch (e) {
  if (e.type === 'user_email_not_found') {
    redirectTo('add-email');
  }
}

Prevention

When it happens

Trigger: POST /v1/account/verification for an account created via phone, OAuth, or anonymous sessions where `user.email` is empty.

Common situations: 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.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


AI-assisted analysis of appwrite/appwrite@7eab5f1970 (2026-09-16). Data as JSON: /api/errors/d2403dacc3466da9. Report an issue: GitHub.

Appendix: source

Thrown at app/controllers/api/account.php:5596

    ->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)
    ->inject('request')
    ->inject('response')
    ->inject('project')
    ->inject('platform')
    ->inject('user')
    ->inject('dbForProject')
    ->inject('locale')
    ->inject('queueForEvents')
    ->inject('publisherForMails')
    ->inject('proofForCode')
    ->inject('authorization')
    ->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) {
        if (empty(System::getEnv('_APP_SMTP_HOST'))) {
            throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled');
        }

        if (empty($user->getAttribute('email'))) {
            throw new Exception(Exception::USER_EMAIL_NOT_FOUND);
        }

        if ($user->getAttribute('emailVerification')) {
            throw new Exception(Exception::USER_EMAIL_ALREADY_VERIFIED);
        }

        if ($phrase === true) {
            $phrase = (new Phrase())->generate();
        }

        $secret = $proofForCode->generate();
        $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), TOKEN_EXPIRATION_OTP));

        $verification = new Document([
            '$id' => ID::unique(),
            'userId' => $user->getId(),
            'userInternalId' => $user->getSequence(),
            'type' => TOKEN_TYPE_VERIFICATION_OTP,

View on GitHub (pinned to 7eab5f1970)