Skip to content
alizeinodin edited this page Sep 12, 2026 · 8 revisions

SMSApi

A Laravel SMS package for Iranian providers. With this package, Laravel users can send SMS messages through sms.ir, Kavenegar, Ghasedak, Melipayamak, Farazsms, Magfa, IPPanel, and many other local gateways — using one consistent API.

It also supports popular messengers (Telegram, WhatsApp, Bale, …), automatic failover when a provider fails, named templates (OTP / verify patterns), queues, Laravel notifications, and an optional OTP vault (generate → HMAC store → verify).

composer require alizeinodin/smsapi
php artisan smsapi:install
use Alizeinodin\SmsApi\Facades\Sms;

Sms::send('09121234567', 'Hello');

Sms::failover(['smsir', 'kavenegar'])->send('09121234567', 'Hello');

Sms::template('otp-login')->to($user)->send(['CODE' => '12345']);

Features

Feature Description
Multi-driver Switch providers without changing your app code
Failover Try the next gateway if one is down or returns an error
Templates Map one logical name (e.g. otp-login) to each provider’s pattern ID
Queues Dedicated queues / retries for OTP vs marketing traffic
OTP via SMS or mail Deliver templates over sms, mail, or both
OTP vault (optional) Generate, store (HMAC), and check codes with TTL & attempt limits
Notifications Built-in Laravel sms notification channel
Testing Sms::fake() assertions
Modular install Logging, webhooks, HTTP API, resilience — enable only what you need

Delivery vs OTP vault

SMSApi is a messaging package, not a full auth system by default.

  • Sms::otp() / Sms::template() — send a code you already created
  • Sms::challenge() — optional vault: generate + store + verify

See OTP vault for details.


Quick setup

SMSAPI_DRIVER=smsir
SMSAPI_API_KEY=your-api-key
SMSAPI_LINE_NUMBER=30007

# Local without a real panel:
# SMSAPI_DRIVER=array
php artisan smsapi:install otp          # optional vault
php artisan smsapi:install logging      # optional sms_logs
php artisan smsapi:install resilience   # optional rate limit / circuit breaker

Documentation

Clone this wiki locally