Search
Send SMS to Any Mobile Number Using Laravel 13 Step by Step Guide

Send SMS to Any Mobile Number Using Laravel 13 Step by Step Guide

Sending SMS is an essential feature for many applications — whether it’s an eCommerce store, education platform, or customer service system. SMS allows you to send OTP codes, promotional offers, or subscription messages directly to your users’ phones. In this tutorial, we’ll learn how to send SMS in Laravel 12 step by step. We’ll build a simple SMS form and integrate it with a third-party SMS API.

Step 1: Install Laravel Project

If you don’t have a Laravel project yet, create one using Composer:

composer create-project laravel/laravel sms-send

Step 2: Create Routes

Add routes for the SMS form and sending messages in routes/web.php:

use App\Http\Controllers\SmsController;

Route::get('/sms-form', [SmsController::class, 'sms_form'])->name('sms.form');
Route::post('/sms-send', [SmsController::class, 'sms_send'])->name('sms.send');

Step 3: Create Blade View (SMS Form)

Create a simple form to collect the phone number and message:

resources/views/sms-form.blade.php

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
  <title>Send SMS in Laravel 12</title>
</head>
<body>
  <div class="container mt-5">
    <div class="row justify-content-center">
      <div class="col-lg-6">
        <h2 class="mb-4">Send SMS with Laravel 12</h2>
        <form action="{{ route('sms.send') }}" method="POST">
          @csrf
          <div class="mb-3">
            <label for="phone" class="form-label">Phone Number</label>
            <input type="text" class="form-control" name="phone" id="phone" required>
          </div>
          <div class="mb-3">
            <label for="message" class="form-label">Message</label>
            <input type="text" class="form-control" name="message" id="message" required>
          </div>
          <button type="submit" class="btn btn-primary">Send SMS</button>
        </form>
      </div>
    </div>
  </div>
</body>
</html>

Step 4: Create SMS Controller

php artisan make:controller SmsController

Then update it like this:

app/Http/Controllers/SmsController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SmsController extends Controller
{
    public function sms_form()
    {
        return view('sms-form');
    }

    public function sms_send(Request $request)
    {
        $phone = $request->phone;
        $message = $request->message;

        // Use your third-party SMS API here (example: BD Bulk SMS)
        $url = "https://api.bdbulksms.net/api.php?json";
        $token = "your_valid_api_token"; // Replace with your real token

        $data = [
            'to'      => $phone,
            'message' => $message,
            'token'   => $token
        ];

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $response = curl_exec($ch);
        curl_close($ch);

        return back()->with('success', 'SMS sent successfully!');
    }
}

Step 5: Use a Third-Party SMS API

To send SMS in Laravel, you need to sign up with an SMS provider such as:

Each provider gives you an API key/token which you must replace in the controller.

Now your Laravel 12 application can send SMS messages to any phone number!

With this setup, you can:

  • Send OTP SMS for login/signup

  • Send Promotional SMS to customers

  • Send Transactional notifications

  • Send Order sms

Using Twilio? If you prefer Twilio over a custom local SMS gateway, follow our Send SMS in Laravel 12 Using Twilio API (Step-by-Step Guide).

🎯 Interactive Skill Assessment
Laravel Challenge: How Well Do You Know the PHP Framework Devs Love?

Test what you just learned with 31 interactive multiple-choice questions and instant explanations.

Start Free Quiz
  • Updated: Nov 24, 2026
  • 5674

Tags

Share This:

You May Also Like Below Articles

Handpicked related tutorials and step-by-step developer guides to continue learning.