A simple Flask project to implement Email OTP (One-Time Password) verification.
This project allows users to verify their email addresses securely using OTPs sent via email.
- Generate secure OTPs for email verification
- Send OTPs to user email using Flask-Mail
- Verify OTP input by the user
- Easy to integrate into existing Flask projects
- Beginner-friendly and lightweight
flask_email_otp/
│── app.py
│── templates/
│ ├── index.html
│ ├── verify.html
│── static/
│── venv/
│── requirements.txt
│── README.md
git clone https://github.com/your-username/flaskemailotp.git
cd flaskemailotppython -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windowspip install -r requirements.txtEdit app.py and configure the email settings:
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'your-email@gmail.com'
app.config['MAIL_PASSWORD'] = 'your-email-password-or-app-password'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
⚠️ For Gmail, you may need to generate an App Password if using 2FA. Never commit your email credentials to GitHub.
python app.pyOpen http://127.0.0.1:5000 in your browser.
- Enter your email in the input form.
- Click Send OTP.
- Check your email for the OTP.
- Enter the OTP in the verification form to confirm your email.
Flask==3.0.3
Flask-Mail==0.9.1Install via:
pip install -r requirements.txt- Never expose your email credentials in public repositories.
- Use environment variables or secret managers in production.
- OTPs expire after a short period to maintain security.
Pull requests are welcome!
Improve features, fix bugs, or enhance the UI.
This project is licensed under the MIT License – see the LICENSE file for details.