# Verify email with code?

**URL:** <https://community.auth0.com/t/verify-email-with-code/115201>\
**Category:** Get Help\
**Tags:** one-time-password-otp-factor, mfa\
**Created:** [September 1, 2023, 10:01am UTC](https://community.auth0.com/t/verify-email-with-code/115201 "2023-09-01T10:01:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bookdrive.lokd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bookdrive.lokd/32/50206_2.png) [@bookdrive.lokd](https://community.auth0.com/u/bookdrive.lokd)\
**Post date:** [September 1, 2023, 10:01am UTC](https://community.auth0.com/t/verify-email-with-code/115201/1 "2023-09-01T10:01:29Z")

</div>

I want when the user’s signup the email\_verified : false is returned. But i want the user to recieve a verification OTP on their mail, which they will enter on the auth0 page and then i receives the email\_verified = true eveytime when a new user signup. How do I achieve this functionality? I would prefer a detailed process.

---

<div class="post-metadata">

**Author:** ![suchislife801](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/suchislife801/32/50280_2.png) [@suchislife801](https://community.auth0.com/u/suchislife801)\
**Post date:** [September 1, 2023, 3:44pm UTC](https://community.auth0.com/t/verify-email-with-code/115201/2 "2023-09-01T15:44:35Z")

</div>

### Steps to Implement Email Verification with OTP in Auth0:

#### 1. Auth0 Dashboard Configuration:

- Go to Auth0 Dashboard \> Rules \> Create Rule.
- Choose “Email Verification” template.
- Modify the rule to send OTP instead of a link.

#### 2. Auth0 Rule Code:

```javascript
function (user, context, callback) {
  if (user.email_verified) {
    return callback(null, user, context);
  }
  
  // Generate OTP and send via email
  // You can use Auth0's API or third-party services to send OTP
  // Store OTP for later verification
  
  // Redirect user to OTP verification page
  context.redirect = {
    url: "YOUR_OTP_VERIFICATION_PAGE_URL"
  };
  
  return callback(null, user, context);
}

```

#### 3. OTP Verification Page:

- Create a page to input OTP.
- Use Auth0.js or Auth0 SDK to verify OTP.

#### 4. Verify OTP:

```javascript
// Use Auth0 API to verify OTP
// If OTP is valid, set `email_verified` to true

```

#### 5. Finalize Rule:

- After OTP verification, redirect back to the application.
- Update `email_verified` in the user profile.

#### 6. Client-Side:

- After successful login, check `email_verified` in the user’s profile.

#### 7. Server-Side (Optional):

- You can also check `email_verified` server-side for extra security.

#### 8. Done:

- Now, `email_verified` should be `true` for users who have verified their email via OTP.

This is a high-level overview. Each step can have its own complexities depending on your specific requirements.

---

<div class="post-metadata">

**Author:** ![cdascal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cdascal/32/53924_2.png) [@cdascal](https://community.auth0.com/u/cdascal)\
**Post date:** [January 14, 2024, 4:47pm UTC](https://community.auth0.com/t/verify-email-with-code/115201/3 "2024-01-14T16:47:06Z")

</div>

Hi @ [suchislife801](https://community.auth0.com/u/suchislife801)  
Would you please help with an updated guide ? I believe “rules” are deprecated and no longer available for new tenants. I know it’s a lot to ask, that would save my day

---

<div class="post-metadata">

**Author:** ![margot](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/margot/32/33649_2.png) [@margot](https://community.auth0.com/u/margot)\
**Post date:** [February 27, 2024, 1:14am UTC](https://community.auth0.com/t/verify-email-with-code/115201/4 "2024-02-27T01:14:14Z")

</div>

Same question as @cdascal - Would appreciate guidance about how to achieve the same via Actions now that rules are being deprecated.

Thoughts @suchislife801 or anyone else?

---

<div class="post-metadata">

**Author:** ![stephanie.akpakoun](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.akpakoun/32/51895_2.png) [@stephanie.akpakoun](https://community.auth0.com/u/stephanie.akpakoun)\
**Post date:** [February 27, 2024, 6:21pm UTC](https://community.auth0.com/t/verify-email-with-code/115201/5 "2024-02-27T18:21:15Z")

</div>

Here is a code example from an Auth0 SA:

> <https://github.com/abbaspour/actions-gallery/blob/main/post-login/validate-email/validate-email.js>

---

<div class="post-metadata">

**Author:** ![salmanmian54321](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/salmanmian54321/32/55497_2.png) [@salmanmian54321](https://community.auth0.com/u/salmanmian54321)\
**Post date:** [March 9, 2024, 1:18am UTC](https://community.auth0.com/t/verify-email-with-code/115201/6 "2024-03-09T01:18:46Z")

</div>

Hi @cdascal , Did you find a way to implement verify email with code ? I tried doing so by going in branding → email template → then choosing verification email with code. we also have to enable custom email provider by going in email provider and enabling “use my own email provider” for that.

I tried sending email while testing it from the dashboard in email template section. it worked over there but the same is not working as when signing up user from my app. please let me know if you have figured out a way to implement it.

Thanks

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [February 18, 2025, 5:58pm UTC](https://community.auth0.com/t/verify-email-with-code/115201/7 "2025-02-18T17:58:37Z")

</div>

Hello everyone!

Thank you for posting this question on the community and I am sorry regarding the late reply to your inquiry!

As an alternative solution to sending an email using the email template where an email domain is required you can go to Authentication → Databases → Select your database → Attributes → Email → … ( three dots on the side) → Configure → Select OTP. Make sure that **Allow Signups with Email** is **Required** and check **Verify Email on Signup**.

Let me know if you have any other questions by leaving a reply or posting again on the community!

Kind Regrads,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 4, 2025, 5:59pm UTC](https://community.auth0.com/t/verify-email-with-code/115201/9 "2025-03-04T17:59:37Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
