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.
You mean for verification?
yes. also for password resets.
No need of separate domain. You can verfiy users by create a separate /verify route.
Recommended threads
- Project Paused Despite Daily Active Usag...
I noticed that my project was automatically **paused**, even though it is actively being used. The project is an **attendance application** that is used daily b...
- Hi Appwrite Support Team,My project has ...
Details: Project ID: 69a69f6f00113ed0e8e4 Region: SFO (sfo.cloud.appwrite.io) Error Response: Affected: ALL endpoints ā Functions, Databases, Storage, Health, ...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...