HOW TO VERIFY OTP USING PYTHON

Akshay Ak
2 min readMay 18, 2021

PYTHON MINI PROJECT:

We are here to see how to send an otp to an email and verify whether it is correct or not.

This can be done in many ways,now I use python language to perform this task.

Firstly, I will start by importing the necessary Python library that we need for this task:

@guvi.com

import math — To use mathematical functions under this module, you have to import the module using import

import random — imports the random module, which contains a variety of things to do with random number generation

Import smtplib — python provides smtplib module, which defines an SMTP client

session object that can be used to send mail to any Internet machine with an SMTP

Secondly,generate a random number and store it in a variable which will be sent as otp to the users.

  • With the help of random function a random number is generated.
  • Now you should create your gmail(host mail) app password to send the mails.
  • After you create your app password for your Gmail account you will get a key.
@guvi

In the above code enter your email & app password.

COMPLETE CODE

******

Output:

Thus executing the code you can send an otp to particular mail and verify it.rt

for further details sign in to www.guvi.io

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Akshay Ak
Akshay Ak

Written by Akshay Ak

0 Followers

JUST A VERY COMMAN MAN

No responses yet

Write a response