Email verification

We all know that email-verification plays a significant role in today’s world for security reasons. In the process of email verification, a random number, text, and combination of both sent to the user mail id. This verification code sometimes also comes with the time limit, which is mostly in between 5-15 minutes only. After that period of time, code gets expired, and the web application also denies to accept that code. To complete the verification, the user has to start the process of confirmation again by requesting the new one verification code, or we can call it  “one-time password.”  Nowadays, several websites use the mobile number in the place of mail id and also use both them as an alternate of each other.

Example

In this example, there are three files. Two of them are html files, and they must be saved in the template folder. The main python script file is saved in the root folder.

  1. Homepage.html
  • Verify.html
  • Mail.py

Output

The above script displays a prompt to the user to enter the e-mail id for sending the mail containing the one-time password(OTP), as shown below.

Flask Email verification

After clicking on the submit button, another template is displayed that asks for the one time password that comes in the received mail. Enter the one-time password, as shown below.

Flask Email verification

In the background, the validate() function compares the user-entered password or OTP with the password that was randomly generated and mailed to the user. If both the password are matched, then a message of  “success” is displayed to the user.

Pin It on Pinterest

Share This