This project demonstrates how to implement OTP (One-Time Password) verification using Python and email. OTP verification is commonly used in applications to authenticate users and ensure the security of sensitive operations.
To run this project, you need the following:
- Python (version 3.6 or later)
- SMTP server details (for sending emails)
- Clone this repository or download the source code.
- Open a terminal or command prompt and navigate to the project directory.
- Install the required dependencies by copying the code from import section.
Before running the project, you need to configure the following:
-
SMTP server details: Open the
config.py
file and enter the details of your SMTP server, such as host, port, username, and password.# SMTP server configuration SMTP_SERVER = 'your_smtp_server_host' SMTP_PORT = your_smtp_server_port SMTP_USERNAME = 'your_smtp_username' i.e your email id SMTP_PASSWORD = 'your_smtp_password' i.e your email password
-
Sender and recipient email addresses: In the
otp_verification.py
file, update thesender_email
andreceiver_email
variables with the appropriate email addresses.# Email addresses sender_email = 'your_sender_email@example.com' receiver_email = 'your_recipient_email@example.com'
To run the OTP verification process, follow these steps:
-
Open a terminal or command prompt and navigate to the project directory.
-
Run the following command:
python otp_verification.py
-
The program will generate a random OTP and send it to the specified email address.
-
Check your email inbox and note down the received OTP.
-
Enter the OTP in the terminal or command prompt when prompted.
-
The program will validate the entered OTP and display a success message if it matches.
You can customize the OTP length, email subject, and email content by modifying the otp_verification.py
file. Look for the following variables and update them according to your requirements:
- 'otp_length'
email_subjects
: The subject line of the verification emailemail_body
: The content of the verification email
This project provides a simple implementation of OTP verification using Python and email. You can integrate this code into your applications to add an extra layer of security to user authentication and sensitive operations. Feel free to modify and enhance the code as per your specific requirements.