How to Send SMS with and Laravel/Lumen PHP

Posted on

Companies need to send SMS for all kinds of reasons: Marketing campaigns, OTP2FA, informing their customers about new products or special offers or just releasing a time critical announcement to a large group of recipients.

Whatever the use case, with SMS achieving open rates ofover 98% within the first few minutes, more and more businesses rush to intergrate SMS messaging in their workflows.

This step by step guide will show you how to easily send bulk SMS from your website using Laravel / Lumen and

What we need

We assume that you already have the following

  • Terminal (Shell Command Line)
  • Composer installed
  • Familiarity with PHP
  • Familiarity with Laravel (5+)
  • Existing Laravel (5+) project
  • An account and your credentials ready:
    • Create an account in if you do not have one
    • Request for API credentials after you login. To request an API client, please click on API Clients in the navigation bar and then “Create” if you haven’t already created one before.


If you haven’t set up Laravel yet, go to


You need to have a working account on with sufficient balance loaded to be able to use this package. If you do not have one, please get one here.

Require package with composer.

$ composer require intergo/

You might need to add Intergo\SmsTo\ServiceProvider::class, to the providers array config/app.php if your Laravel version is less than 5.5.


Publish the configuration file

$ php artisan vendor:publish --provider="Intergo\SmsTo\ServiceProvider"

You will get a config file named smsto.php in your config directory. Customise the defaults to your personal configurations.


  return [
      'client_id' => env('SMSTO_CLIENT_ID'),
      'client_secret' => env('SMSTO_CLIENT_SECRET'),
      'username'=> env('SMSTO_EMAIL'),
      'password' => env('SMSTO_PASSWORD'),
      'scope' => '*',
      'sender_id' => env('SMSTO_SENDER_ID'),
      'callback_url' => env('SMSTO_CALLBACK_URL'),


Change or add configuration in you .env file


Create Controller and View

Run the following command to generate Laravel Controller

$ php artisan make:controller SmsController

It will generate the file app\Http\Controllers\SmsController.php

Open SmsController.php in your text editor and add SmsTo class

    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use SmsTo;

The next step is to create the view file. This file will contain the HTML fields that we need to send the bulk SMS.

In your terminal run the command:

$ touch resources/views/smsto/sendsms.blade.php

Open the file in resources/views/smsto/sendsms.blade.php then copy and paste the following code:

         <form method='POST'>
            @foreach($errors->all() as $error)
            <li><strong>{{ $error }}</strong></li>
            <strong>{{ session('success') }}</strong>
            <label for="to">Comma Separated Numbers</label>
            <input type='text' name='to' />
            <textarea name='messages'></textarea>
            <button type='submit'>Send</button>

Open your web.php file located on routes folder and paste the following code:

Route::get('/sms/send', 'SmsController@sendSms');
Route::post('/sms/send', 'SmsController@postSendSms');

Open up your SmsController.php and the code should look like below:

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use SmsTo;
class SmsController extends Controller
    public function sendsms()
        return view('smsto.sendsms');
    public function postSendSms(Request $request)
            'to' => 'required',
            'messages' => 'required',
        $to = explode(',', request('to'));
        $response = SmsTo::setMessage(request('messages'))
        if ($response['success'] == true) {
            return back()->with('success', 'Messages has been queued and ready to be sent.');
        } else {
            return back()->withErrors($response['errors']);

Test and Send SMS!

Open your browser and go to /sms/send or anywhere you set up your Laravel routes. Fill up numbers and messages then click the submit button.

Wrapping Up

You experienced how easy and efficient it is to set up and send bulk SMS or notification SMS using Sign up now and we can give you free credits for you to test the power of

For a more detailed documentation on the topic please refer to our page on GitHub.