laravel-intellisms maintained by zanysoft
Laravel IntelliSMS Package
A Laravel notification channel for sending SMS messages using the IntelliSMS API.
Features
- Laravel Notifications Integration - Seamless integration with Laravel's notification system
- Multiple Recipients - Send SMS to single or multiple phone numbers
- Customizable Sender ID - Set custom "from" identifier for your messages
- Balance Checking - Check your IntelliSMS account balance
- Error Handling - Comprehensive exception handling with provider responses
- Configuration - Easy environment-based configuration
Installation
Install the package using Composer
composer require zanysoft/laravel-intellisms
Register the Service Provider
The package is auto-discovered by Laravel, but you can manually register it in bootstrap/providers.php:
'providers' => [
\IntelliSms\LaravelIntelliSms\IntelliSmsServiceProvider::class,
],
Publish the configuration file
php artisan vendor:publish --tag=intellisms-config
Configuration
Add the following environment variables to your .env file:
INTELLISMS_ACCESS_KEY=your_access_key_here
INTELLISMS_SECRET_KEY=your_secret_key_here
INTELLISMS_FROM=YourSenderID
Usage
Using Notifications
Create a notification that sends SMS using the IntelliSMS channel:
php artisan make:notification SendSmsNotification
In your notification class:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use ZanySoft\LaravelIntelliSms\Messages\IntelliSmsMessage;
class SendSmsNotification extends Notification
{
public function via($notifiable)
{
return ['intellisms'];
}
public function toIntelliSms($notifiable)
{
return IntelliSmsMessage::create('Hello, this is your SMS message!')
->from('MySenderID')
->to($notifiable->phone_number);
}
}
Sending Notifications
use App\Notifications\SendSmsNotification;
$user->notify(new SendSmsNotification());
Model Setup
On your notifiable model, add the routeNotificationForIntelliSms() method:
public function routeNotificationForIntelliSms($notification)
{
return $this->phone;
}
Sending Direct SMS
Facade usage for sending SMS:
use ZanySoft\LaravelIntelliSms\Facades\IntelliSms;
// Send SMS
$response = IntelliSms::make('Hello, World!')
->to('27123456789') // Single number or array of numbers
->from('MyApp') // from is optional, uses config if not provided
->send();
// Check balance
$balance = IntelliSms::make()->balance();
Exception
Handle SMS sending errors:
use ZanySoft\LaravelIntelliSms\Exceptions\IntelliSmsException;
try {
IntelliSms::make('Hello, World!')
->to('27123456789') // Single number or array of numbers
->send();
} catch (IntelliSmsException $e) {
$message = $e->getMessage(); // Error message
$response = $e->response(); // Full provider response array
Log::error('SMS sending failed', [
'error' => $message,
'response' => $response,
]);
}
Contact
If you discover any issues, please contact me zanysoft.us@gmail.com instead of using the issue tracker.
License
This package is open-sourced software licensed under the MIT License. See the LICENSE file for details.