abolfazlrastegar/laravel-sms
Larablocks Analysis
abolfazlrastegar/laravel-sms works with any PHP project: the latest release (v2.0.0, Jul 18, 2023) doesn't depend on Laravel.
Recommendation checks
Use with careUse with care: meets 0 of 3 checks.
- No release in the last 12 months (last: Jul 18, 2023)
- 2 downloads a month (needs 10,000)
- 3 GitHub stars (needs 100)
State
Quiet- Last stable release: Jul 18, 2023.
- No releases in the last 12 months.
- First released: Jun 21, 2022.
- Monthly downloads: 2.
- 2 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.
| Install | |
|---|---|
composer require abolfazlrastegar/laravel-sms |
|
| Latest Version: | v2.0.0 |
| PHP: | ^7.4 || ^8.1 |
| License: | MIT |
| Last Updated: | Nov 23, 2026 |
| Links: | GitHub · Packagist |
Laravel SMS
A Laravel package with a common API for Kavenegar, SMS.ir and Melipayamak.
Requirements
- PHP 7.4+ (the host application's PHP version must also satisfy the selected Laravel release)
- Laravel 8, 9, 10, 11, 12 and 13
Laravel's minimum PHP versions vary by major release: Laravel 8 supports PHP 7.4; Laravel 9 requires PHP 8.0.2+; Laravel 10 requires PHP 8.1+; Laravel 11 and 12 require PHP 8.2+; Laravel 13 requires PHP 8.3+.
Installation
composer require abolfazlrastegar/laravel-sms
php artisan vendor:publish --provider="Abolfazlrastegar\\LaravelSms\\Providers\\SmsServiceProvider" --tag=config
php artisan vendor:publish --provider="Abolfazlrastegar\\LaravelSms\\Providers\\SmsServiceProvider" --tag=migrations
php artisan migrate
Configuration
Set credentials in .env; never commit provider keys.
SMS_DRIVER=Kavenegar
SMS_MODE=sync
SMS_TIMEOUT=15
SMS_LOG_ENABLED=true
SMS_QUEUE=sms
SMS_QUEUE_TRIES=3
SMS_QUEUE_TIMEOUT=60
KAVENEGAR_API_KEY=
SMSIR_API_KEY=
MELIPAYAMAK_USERNAME=
MELIPAYAMAK_PASSWORD=
MELIPAYAMAK_FROM=
Sending mode is controlled explicitly with SMS_MODE. The default is sync, so installing the package does not change the application's existing behavior. No application-level Job class is required.
SMS_MODE=sync: sends immediately and returns the provider response.SMS_MODE=queue: dispatches the package's internalSendSmsJobusing Laravel'squeue.defaultconnection (for exampledatabaseorredis).- The queue name defaults to
smsand can be changed withSMS_QUEUE. - Attempts and timeout are configurable with
SMS_QUEUE_TRIESandSMS_QUEUE_TIMEOUT.
Delivery logs
The package can persist send lifecycle records in the sms_logs table for both sync and queue modes. Logging is enabled by default and can be disabled with SMS_LOG_ENABLED=false. Publish the package migration and run php artisan migrate to create the table. If the migration has not been run, logging safely becomes a no-op and does not interrupt SMS sending.
The log stores the driver, operation, masked recipient number(s), lifecycle status, provider message ID/response code when available, attempt count, duration, and error message. Message bodies, templates, parameters, and provider credentials are never intentionally stored. Keep in mind that exception text comes from HTTP/provider libraries; do not expose raw log records publicly.
Statuses include queued, processing, retrying, sent, and failed. The metadata JSON column is reserved for safe, non-sensitive additional context.
Configure the queue connection in the host Laravel application as usual and run its queue worker, for example:
php artisan queue:work --queue=sms
For the database queue driver, the host application must also have Laravel's standard queue table migration installed. The package does not create or modify Laravel's queue tables.
After changing environment values in production, clear/rebuild Laravel's config cache.
Usage
use Abolfazlrastegar\\LaravelSms\\Facades\\Sms;
Sms::make('kavenegar')
->mobile('09123456789')
->template('verify')
->params(['token' => '123456'])
->sendVerifyCode();
Send a regular SMS:
Sms::make('smsir')
->mobile(['09123456789', '09123456780'])
->message('Your message')
->params(['lineNumber' => '3000XXXX'])
->sendMessages();
Group send requires matching recipient/message counts. Kavenegar additionally requires a sender array with the same number of entries.
Sms::make('kavenegar')
->mobile(['09123456789', '09123456780'])
->message(['Message one', 'Message two'])
->params(['sender' => ['1000', '1000']])
->sendMessageGroup();
Voice calls are supported by Kavenegar only. Unsupported driver capabilities throw UnsupportedFeatureException.
Driver notes
- Kavenegar uses its GET API with query parameters; Laravel encodes values safely.
- SMS.ir uses the
X-API-KEYheader and JSON request bodies. - Melipayamak uses its REST SendSMS and BaseServiceNumber endpoints. For verification, pass the text template in
params(['text' => '...'])and the provider body ID astemplate(). - Queue workers retry failed jobs according to the configured attempt count. Be aware that retrying after a provider timeout can produce duplicate SMS messages.
- A successful API response means the provider accepted the request; it does not prove delivery to the handset.
Testing
composer install
vendor/bin/phpunit
Tests use Laravel's HTTP fake and never send real SMS messages.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| v2.0.0 | ^7.4 || | MIT | |
| v1.0.2 | ^7.4 || | MIT | |
| v1.0.1 | ^7.4 || | MIT | |
| v1.0.0 | ^7.4 || | MIT |