Skip to content

About

you can send email code and verify user email

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTP Email Service

Send OTP codes by email and verify user email addresses.


Features

Feature Description
Send OTP Generate and send verification code via email
Verify OTP Validate user email verification code
SMTP Support Works with Gmail, Outlook, custom SMTP
Django Ready Easy integration with Django projects
Secure Expiration time and retry support
Reusable Can be used for login, signup, password reset

SMTP Connection Test

Test SMTP with Telnet

telnet EMAIL_HOST EMAIL_PORT

Example:

telnet smtp.gmail.com 587

Test Email Sending in Django

Open Django shell:

python manage.py shell

Run:

from django.core.mail import send_mail
from django.conf import settings

send_mail(
    subject='Test Subject',
    message='This is a test email.',
    from_email=settings.EMAIL_HOST_USER,
    recipient_list=['example@gmail.com'],
    fail_silently=False,
)

Environment Variables

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend

EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587

EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-password

EMAIL_USE_TLS=True
EMAIL_USE_SSL=False

DEFAULT_FROM_EMAIL=your-email@gmail.com

OTP Authentication Flow

Step Action
1 User enters email
2 System generates OTP code
3 OTP sent via email
4 User enters received code
5 System verifies OTP
6 User authenticated / verified

Suggested Database Tables

OTP Codes Table

Column Type Description
id UUID / Integer Primary key
email String User email
code String OTP code
is_used Boolean Verification status
expired_at DateTime Expiration time
created_at DateTime Created timestamp

Login Attempts Table

Column Type Description
id UUID / Integer Primary key
email String User email
ip_address String Client IP
status String Success / Failed
created_at DateTime Login timestamp

Security Recommendations

  • OTP expiration: 2–5 minutes
  • Limit resend attempts
  • Limit verification attempts
  • Store hashed OTP codes
  • Add rate limiting
  • Log suspicious activity

Example Use Cases

  • Email verification
  • Password reset
  • Two-factor authentication (2FA)
  • Passwordless login
  • Signup verification

About

you can send email code and verify user email

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages