📲 SMS OTP Sender

Production one-time-code SMS for your website — generated, sent and verified by the platform's own script, through any HTTP sending gateway. Runs inside the same install; no extra service.

Requirement: a text-SMS SENDING endpoint from any gateway (SMSCodex Send, Twilio-compatible, or any HTTP API that accepts to + message). Numbers rented on this platform are for receiving; OTP sending uses your own sender gateway.

Setup

1Configure the transport (environment)

export ZALAF_SMS_SEND_URL='https://your-gateway/sms?user=USER&pass=PASS&to={to}&msg={text}'
export ZALAF_SMS_SEND_AUTH='Basic xxxx'      # optional
export ZALAF_OTP_TTL=600                     # seconds a code stays valid
export ZALAF_OTP_COOLDOWN=60                 # min gap between resends
Placeholders: {to} {text} {code} {mins}. POST JSON instead? add ZALAF_SMS_SEND_METHOD=POST and ZALAF_SMS_SEND_BODY='{"to":"{to}","message":"{text}"}'.

2Self-test, then send for real

python3 scripts/run.py otp setup                          # shows resolved config
python3 scripts/run.py otp send --to +9639XXXXXXXX --dry-run
python3 scripts/run.py otp send --to +9639XXXXXXXX
python3 scripts/run.py otp verify --to +9639XXXXXXXX --code 123456

3Hook your website to it

// PHP
exec('python3 scripts/run.py otp send --to ' . escapeshellarg($phone));
exec('python3 scripts/run.py otp verify --to ' . escapeshellarg($phone)
     . ' --code ' . escapeshellarg($code), $out, $rc);   // $rc === 0 → verified
In-process (Python/Flask side): import sms_otp; sms_otp.send(phone, tag="signup")

Guarantees

  • Codes are stored hashed only (HMAC with the platform secret) in their own databases/otp.db — never in the main DB, never in logs.
  • Single-use · max 5 wrong tries · per-number cooldown · max 5 active codes per number.
  • Bilingual messages (default --lang en, or ar).
  • Service zeroing and backups of the main app never destroy in-flight codes.

Return to the home page · API documentation