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?
Can you share your AuthContext file or the file where you've created your signup/login function?
function file is too long !!
Ok then share the signup function only
i am doing with simple html (vibe coding ) is it ok
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
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);
// 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);
Firstly, fix this line log("createVerification() response: " + JSON.stringify(res "ok")); to log("createVerification() response: " + JSON.stringify(res) + "ok");
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);
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); ```
Also make sure SMTP is enabled in your Appwrite Console
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?
Yes, I'll explain you this
The flow for your application should be something like this:
- Call
account.create()to create the user. - Call
account.createEmailSession()to log the user in. - User clicks the Verify Email button (your code starts).
- Build
redirectUrl = window.location.origin + "/verify.html". - Call
getCurrentUser()to confirm the user is logged in. - If logged in, call
account.createVerification(redirectUrl). - User receives the verification email.
- User clicks the link and lands on
verify.html. - On
verify.html, callaccount.updateVerification(userId, secret)to complete verification.
Recommended threads
- Auth not working on expo react native
I'm trying to launch a development server with expo go and appwrite as a backend. On my windows pc, I've got a local docker instance of appwrite running as my b...
- createMembership is not sending email wi...
Parameters should be correct. Account and Membership are successfully created. I have a next.js project with localhost origin allowed. I checked spam etc. i...
- Bulk delete failed with 401
- I created a transaction to bulk delete rows in a table has `done` equal `true` follow documentation. But when run, it returns 401 unauthorized error as screen...