🚀 Send SMS & OTPs in Laravel the Laravel way! Laravel Fast2SMS is an open-source package for Fast2SMS API with queues, OTP & DLT support.

How to Send SMS, OTP & DLT Messages in Laravel with Fast2SMS

Reading Time: 3 minutes

SMS is still one of the most reliable channels to reach users instantly. Whether it’s OTP verification, transaction alerts, delivery updates, or marketing campaigns — SMS ensures high visibility, especially in India where mobile penetration is massive.

🚀 Send SMS & OTPs in Laravel the Laravel way! Laravel Fast2SMS is an open-source package for Fast2SMS API with queues, OTP & DLT support.

But integrating SMS in Laravel isn’t always clean. Most providers hand you a raw REST API and leave you to figure out the rest — repetitive boilerplate, manually wiring up queues and retries, and code that doesn’t feel Laravel-native at all.

That’s exactly the problem laravel-fast2sms solves.


What Is Laravel Fast2SMS?

Laravel Fast2SMS is an open-source package that integrates seamlessly with the Fast2SMS API — designed to make SMS sending simple, fluent, and Laravel-friendly, so you can focus on your app instead of SMS plumbing.

What it lets you do

  • ✅ Send Quick SMS, OTP, and DLT messages
  • ✅ Integrate with Laravel queues & scheduling
  • ✅ Monitor your wallet balance from within your app
  • ✅ Use SMS as a Laravel Notification channel
  • ✅ Write clean, chainable, expressive code — the Laravel way

Who it’s for

This package is ideal for:

  • Authentication systems — OTP-based login and 2FA
  • E-commerce stores — order confirmations, delivery updates
  • FinTech apps — instant transaction alerts
  • SaaS platforms — scheduled reminders, automated notifications

If your app targets Indian users, this package will save you hours of integration work.


Requirements

  • PHP 8.3+
  • Laravel 12+
  • A Fast2SMS account with an API key

Step 1: Install the Package

composer require itxshakil/laravel-fast2sms

Supports Laravel auto-discovery — no manual provider registration needed.


Step 2: Configure Fast2SMS

Publish the config file:

php artisan vendor:publish --tag=fast2sms-config

Then update your .env:

FAST2SMS_API_KEY="YOUR_API_KEY"
FAST2SMS_DEFAULT_SENDER_ID="FSTSMS"
FAST2SMS_DEFAULT_ROUTE="dlt"


Step 3: Sending SMS

Quick SMS

use Shakil\Fast2sms\Facades\Fast2sms;
use Shakil\Fast2sms\Enums\SmsLanguage;

// English
Fast2sms::quick('9999999999', 'Hello, this is a Quick SMS!');

// Unicode (Hindi, etc.)
Fast2sms::quick('9999999999', 'नमस्ते! यह एक क्विक एसएमएस है।', SmsLanguage::UNICODE);


DLT SMS

For marketing and transactional messages that require TRAI-registered templates:

use Shakil\Fast2sms\Facades\Fast2sms;

Fast2sms::dlt(
    numbers: '9999999999',
    templateId: 'YOUR_TEMPLATE_ID',
    variablesValues: ['John Doe'],
    senderId: 'YOUR_SENDER_ID'
);


OTP SMS

use Shakil\Fast2sms\Facades\Fast2sms;

Fast2sms::otp('9999999999', '123456');


Fluent Interface

For more control, use the chainable builder:

use Shakil\Fast2sms\Facades\Fast2sms;
use Shakil\Fast2sms\Enums\SmsRoute;

Fast2sms::to('9999999999')
    ->route(SmsRoute::DLT)
    ->senderId('YOUR_SENDER_ID')
    ->templateId('YOUR_TEMPLATE_ID')
    ->variables(['John Doe'])
    ->send();


Step 4: Extra Features

Check Wallet Balance

Monitor your SMS credits directly from your application:

$response = Fast2sms::checkBalance();

if ($response->success()) {
    echo "Wallet Balance: {$response->balance}\n";
    echo "SMS Count: {$response->smsCount}\n";
}


Queueing SMS

The package integrates with Laravel’s job queue system out of the box:

// Queue a Quick SMS
Fast2sms::quickQueue('9999999999', 'Hello from queue!');

// Queue a DLT SMS
Fast2sms::dltQueue(
    numbers: '9999999999',
    templateId: 'YOUR_TEMPLATE_ID',
    variablesValues: ['John Doe'],
    senderId: 'YOUR_SENDER_ID'
);

// Queue an OTP SMS
Fast2sms::otpQueue('9999999999', '123456');

For advanced queue control — custom connections, queue names, delays:

Fast2sms::to('9999999999')
    ->message('Test message')
    ->onConnection('redis')
    ->onQueue('sms')
    ->delay(now()->addMinutes(10))
    ->queue();


Laravel Notifications Channel

Integrate SMS seamlessly into Laravel’s Notification system:

use Illuminate\Notifications\Notification;
use Shakil\Fast2sms\Facades\Fast2sms;
use Shakil\Fast2sms\Enums\SmsRoute;

class LowSmsBalanceNotification extends Notification
{
    public function __construct(
        protected float $balance,
        protected float $threshold
    ) {}

    public function via($notifiable): array
    {
        return ['fast2sms'];
    }

    public function toFast2sms($notifiable)
    {
        return Fast2sms::to($notifiable->phone)
            ->message("Low SMS balance: {$this->balance}. Threshold: {$this->threshold}.")
            ->route(SmsRoute::QUICK)
            ->send();
    }
}

Dispatching the notification:

Notification::route('fast2sms', '9999999999')
    ->notify(new LowSmsBalanceNotification(500, 1000));


Step 5: Error Handling

Always wrap SMS calls in a try-catch to handle failures gracefully:

use Shakil\Fast2sms\Exceptions\Fast2smsException;

try {
    Fast2sms::quick('9999999999', 'Hello World');
} catch (Fast2smsException $e) {
    logger()->error("SMS failed: " . $e->getMessage());
}


Why Use laravel-fast2sms?

FeatureDetail
🚀 Fluent APIExpressive, chainable syntax — reads like Laravel
🎯 All SMS typesQuick, DLT, OTP — all covered
⏳ Queue supportNative Laravel jobs, connections, delays
🔒 DLT compliantWorks with TRAI-registered templates
📡 Balance monitoringCheck credits without leaving your app
📱 NotificationsPlugs into Laravel’s notification system
📦 LightweightNo unnecessary dependencies
🆓 Open sourceMIT licensed, free forever

Roadmap

What’s coming next:

  • ✅ PHP 8.5 support (once released)
  • ✅ Webhook handling for delivery receipts

Conclusion

With laravel-fast2sms, you can integrate Fast2SMS into Laravel in minutes — sending OTPs, notifications, or bulk DLT messages with queue support, balance monitoring, and a fluent API that feels right at home in any Laravel codebase.

👉 Try it today: github.com/itxshakil/laravel-fast2sms

⭐ If you find it useful, star the repo — it helps more Laravel developers discover it.


Found a bug or want to contribute? PRs and issues are always welcome.

How to Send SMS, OTP & DLT Messages in Laravel with Fast2SMS

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox.

We don’t spam! Read our privacy policy for more info.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.