umisms/laravel-sms

Send SMS from your laravel application

1.0.0 2022-01-27 21:05 UTC

This package is not auto-updated.

Last update: 2024-11-15 10:49:36 UTC


README

Laravel SMS allows you to send SMS from your Laravel application using one of over 10 sms providers, or your own sms provider.

Requirements

  • PHP >=7.1

Installation

Step 1

You can install the package via composer:

composer require umisms/laravel-sms

Laravel 5.5 and above

The package will automatically register itself, so you can start using it immediately.

Laravel 5.4 and older

In Laravel version 5.4 and older, you have to add the service provider in config/app.php file manually:

'providers' => [
    // ...
    Umisms\Sms\SmsServiceProvider::class,
];

Lumen

After installing the package, you will have to register it in bootstrap/app.php file manually:

// Register Service Providers
    // ...
    $app->register(Umisms\Sms\SmsServiceProvider::class);
];

Env Keys

SMS_SENDER=

BETASMS_USERNAME=
BETASMS_PASSWORD=

BULK_SMS_NIGERIA_TOKEN=
BULK_SMS_NIGERIA_DND=

GOLD_SMS_247_USERNAME=
GOLD_SMS_247_PASSWORD=

MULTITEXTER_USERNAME=
MULTITEXTER_PASSWORD=

SMART_SMS_TOKEN=

XWIRELESS_API_KEY=
XWIRELESS_CLIENT_ID=

NEXMO_API_KEY=
NEXMO_API_SECRET=

RING_CAPTCHA_APP_KEY=
RING_CAPTCHA_API_KEY=
RING_CAPTCHA_APP_SECRET=

AFRICASTALKING_API_KEY=
AFRICASTALKING_USERNAME=

NIGERIAN_BULK_SMS_USERNAME=
NIGERIAN_BULK_SMS_PASSWORD=

KUDI_SMS_USERNAME=
KUDI_SMS_PASSWORD=

MEBO_SMS_API_KEY=

SMSLIVE247_TOKEN=

INFOBIP_BASE_URL=
INFOBIP_USERNAME=
INFOBIP_PASSWORD=

Step 2 - Publishing files

Run: php artisan vendor:publish --tag=laravel-sms This will move the migration file, seeder file and config file to your app. You can set your sms details in the config file or via env

Step 3 - Adding SMS credentials

  • Add the env keys to your .env file
  • Or edit the config/laravel-sms.php file

Usage

//using betaSMS
use Umisms\Sms\BetaSms;

$sms = new BetaSms();
$sms->text($message)->to(08135087966)->from('MyLaravel')->send();
//returns true if everything went fine. Or false if error occured.
//You can get exception via getException() or get the server response via getResponse()
//exceptions will be logged in your laravel log file

Using Helper function

//MeboSms
$send = send_sms($message, $to, $from, MeboSms::class); //returns true/false

The default SMS provider is Nexmo. You can set the default SMS provider in config/laravel-sms.php e.g 'default' => \Umisms\Sms\Concrete\SmartSmsSolutions::class,, so you can use the helper function like this:

$send = send_sms($message, $to);
//$from is optional and is better set in the config

Available SMS Providers

ProviderURLTested
Nexmohttps://developer.nexmo.com/api/sms#send-an-sms|Yes
AfricasTalkinghttps://build.at-labs.io/docs/sms/sending|Yes|
BetaSmshttps://login.betasms.com.ng/|Yes
MultiTexterhttps://web.multitexter.com/MultiTexter_HTTP_SMS_API 2.0.pdf|Yes
BulkSmsNigeriahttps://www.bulksmsnigeria.com/bulk-sms-api|Yes
GoldSms247https://goldsms247.com/index.php/api|Yes
KudiSmshttps://kudisms.net/api/|Yes
Mebosmshttp://mebosms.com/api-sms|Yes
NigerianBulkSmshttps://nigeriabulksms.com/sms-gateway-api/|Yes
SmartSmsSolutionshttps://docs.smartsmssolutions.com/docs/send-with-basic-route|Yes
RingCaptchahttps://my.ringcaptcha.com/docs/api|No
SmsLive247http://portal.smslive247.com/developer_api/http.aspx|No
XWirelesshttps://xwireless.net/cportal/knowledge-base/article/sms-3|No
InfoBiphttps://dev.infobip.com/send-sms/single-sms-message|No

Creating custom SMS Provider

  • Create a class that extends Umisms\Sms\Concrete\Sms class
  • Implement the send() which makes the request and return bool
  • (Optional) You can add the provider keys to the config/laravel-sms.php