Send OTP codes by email and verify user email addresses.
| 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 |
telnet EMAIL_HOST EMAIL_PORTExample:
telnet smtp.gmail.com 587Open Django shell:
python manage.py shellRun:
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,
)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| 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 |
| Column | Type | Description |
|---|---|---|
| id | UUID / Integer | Primary key |
| String | User email | |
| code | String | OTP code |
| is_used | Boolean | Verification status |
| expired_at | DateTime | Expiration time |
| created_at | DateTime | Created timestamp |
| Column | Type | Description |
|---|---|---|
| id | UUID / Integer | Primary key |
| String | User email | |
| ip_address | String | Client IP |
| status | String | Success / Failed |
| created_at | DateTime | Login timestamp |
- OTP expiration: 2–5 minutes
- Limit resend attempts
- Limit verification attempts
- Store hashed OTP codes
- Add rate limiting
- Log suspicious activity
- Email verification
- Password reset
- Two-factor authentication (2FA)
- Passwordless login
- Signup verification