Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Simple OTP

No security coverage
View on drupal.org

This module provides a service for generating and validating one-time passwords (OTPs) that can be sent via email or SMS. It allows for configuration of OTP length and expiry, and offers customizability for the messages sent to users for verification purposes.

The Simple OTP module provides OTP configuration and service for both email and phone numbers. It helps us to generate and validate OTPs.

We can easily configure and integrate the OTP logic and customize the email or SMS to send an OTP to the user. This module can be used in email or phone number verification.

Features

Here, we are getting two methods generateOtp() and validateOtp() in OTP service. We can send custom OTP emails or SMS to user.

Post-Installation

After installation, we have to first configure the OTP length and OTP Expiry Time (in minutes).

Use the following service in code,

OTP for email

// Generate OTP
$otp_manager = \Drupal::service('simple_otp_service.otp_manager');
$otp = $otp_manager->generateOtp('email', '[email protected]');

// Validate OTP
$is_valid = $otp_manager->validateOtp('email', '[email protected]', '1234');

OTP for phone number

// Generate OTP
$otp_manager = \Drupal::service('simple_otp_service.otp_manager');
$otp = $otp_manager->generateOtp('phone_number', '1234567890');

// Validate OTP
$is_valid = $otp_manager->validateOtp('phone_number', '1234567890', '1234');

Similar projects

https://www.drupal.org/project/otp
https://www.drupal.org/project/otp_service

Activity

Total releases
1
First release
Aug 2025
Latest release
10 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.0.x-dev Dev Aug 18, 2025