Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

OTP Email System (FastAPI)

A small-scale and simple OTP sending and verification system built with Python. Easily integrates into login or signup flows. Uses basic SMTP (Simple Mail Transfer Protocol) and FastAPI libraries.

Features

  • Generate 4-digit OTPs
  • Send OTPs via Gmail SMTP
  • Verify OTPs within configurable expiry
  • Easy to integrate into hackathons or other projects
  • Well-commented code for reference
  • Variables easy to spot and modify according to needs

Setup

Clone the repo:

git clone <repo-url>
cd <repo-folder>

Create a .env file:

SENDER_MAIL=your_email@gmail.com
SENDER_PASSWORD=your_app_password
OTP_EXPIRY=300

Install dependencies:

pip install fastapi uvicorn python-dotenv

Run the Application

Start FastAPI server:

uvicorn main:app --reload

Open in your browser: http://127.0.0.1:8000/docs for Swagger UI.

Usage in Projects

Copy the following files to your project:

logic.py
blueprints.py
config.py

Import OTP functions:

from logic import get_OTP, verify_otp

Send OTP:

get_OTP("user@example.com")

Verify OTP:

verify_otp("user@example.com", "1234")

Notes

  • OTP is valid for OTP_EXPIRY seconds
  • Uses Gmail SMTP (port 587, TLS)
  • Always use Gmail App Password, not your regular Gmail password
  • For production, consider database or Redis storage for OTPs
  • Make sure all the libraries and their complementary files are installed.

AI-Usage (gpt-5)

  • Used for syntactical structure.
  • Used for commenting.
  • Use of MIMEText for mail formatting.
  • Used for README structuring.

About

Small scale OTP sending and verification system using python (SMTP).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages