Skip to content
Back

Emails not coming

  • 0
  • Auth
  • Web
  • Cloud
Harsh
15 Nov, 2025, 13:10

I'm building a simple web app that registers users with an email and password. The user is created successfully in my (auth) page, but the verification email is never sent to their inbox. I've tried multiple times. Could anyone explain how to set up email verification properly?

TL;DR
Developers need to follow a specific flow for email verification: 1. Create the user using `account.create()`. 2. Log in the user with `account.createEmailSession()`. 3. Click the **Verify Email** button. 4. Build the `redirectUrl` using `window.location.origin + "/verify.html"`. 5. Check if the user is logged in with `getCurrentUser()`. 6. If logged in, call `account.createVerification(redirectUrl)`. 7. Ask to ensure SMTP is enabled in Appwrite Console. 8. Fix a line in the code ("createVerification() response"). 9. The snippet
Devika
15 Nov, 2025, 13:11

Can you share your AuthContext file or the file where you've created your signup/login function?

Harsh
15 Nov, 2025, 13:13

function file is too long !!

Devika
15 Nov, 2025, 13:13

Ok then share the signup function only

Harsh
15 Nov, 2025, 13:14

i am doing with simple html (vibe coding ) is it ok

Devika
15 Nov, 2025, 13:15

It's ok and I just want to see your signup flow within the function and check how you're creating users within your app

Harsh
15 Nov, 2025, 13:15

document.getElementById('btnSendVerify').onclick = async () => { try { // Build redirect URL from the current origin so Appwrite CORS origin exactly matches const redirectUrl = window.location.origin + "/verify.html"; log("Using redirect URL: " + redirectUrl);

TypeScript
    // Ensure user is logged in (account.get() will succeed only if a valid session exists)
    const user = await getCurrentUser();
    if (!user) {
      log("No logged-in user detected. Please login first (createSession).");
      return;
    }

    // Call createVerification -> Appwrite will send the email
    const res = await account.createVerification(redirectUrl);
    log("createVerification() response: " + JSON.stringify(res || "ok"));
    log("Check your inbox (and spam). If no email arrives, check Appwrite Console -> Project -> Logs -> Messaging.");
  } catch (e) {
    // log entire object for easier debugging (redact secrets before sharing)
    log("Send verify error: " + (e.message || JSON.stringify(e)));
  }
};

// Helpful hint: show current origin for CORS debugging
log("Page origin: " + window.location.origin);
Devika
15 Nov, 2025, 13:21

Firstly, fix this line log("createVerification() response: " + JSON.stringify(res "ok")); to log("createVerification() response: " + JSON.stringify(res) + "ok");

Devika
15 Nov, 2025, 13:23

Here's the improved version of your code ``` document.getElementById('btnSendVerify').onclick = async () => { try { const redirectUrl = window.location.origin + "/verify.html"; log("Using redirect URL: " + redirectUrl);

TypeScript
const user = await getCurrentUser();
if (!user) {
  log("No logged-in user detected. Please login first.");
  return;
}

const res = await account.createVerification(redirectUrl);
log("createVerification() response: " + JSON.stringify(res) + " ok");
log("Check your inbox (and spam). If no email arrives, check Appwrite Console -> Messaging Logs.");

} catch (e) { log("Send verify error: " + (e.message || JSON.stringify(e))); } };

log("Page origin: " + window.location.origin); ```

Devika
15 Nov, 2025, 13:24

Also make sure SMTP is enabled in your Appwrite Console

Harsh
15 Nov, 2025, 13:27

Okay, so I tested the app again with the verification code. Here's what I found: I have to sign up the user, then log them in again separately, and then click a 'send verification' button for the email to finally come through.

I want to understand the proper flow for this. I'll figure out the code myself, but could you explain the logic? What steps should happen first for email verification?

Devika
15 Nov, 2025, 13:30

Yes, I'll explain you this

Devika
15 Nov, 2025, 13:38

The flow for your application should be something like this:

  1. Call account.create() to create the user.
  2. Call account.createEmailSession() to log the user in.
  3. User clicks the Verify Email button (your code starts).
  4. Build redirectUrl = window.location.origin + "/verify.html".
  5. Call getCurrentUser() to confirm the user is logged in.
  6. If logged in, call account.createVerification(redirectUrl).
  7. User receives the verification email.
  8. User clicks the link and lands on verify.html.
  9. On verify.html, call account.updateVerification(userId, secret) to complete verification.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more