1. Go to this page and download the library: Download kaydee123/msg91-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Kaydee123\Msg91\Msg91Client;
class SmsController extends Controller
{
protected $msg91;
public function __construct(Msg91Client $msg91)
{
$this->msg91 = $msg91;
}
public function sendSms()
{
$response = $this->msg91->sms()
->template('YOUR_TEMPLATE_ID')
->numbers('919876543210')
->send();
}
}
// Retry as text SMS
$response = Msg91::otp()
->number('919876543210')
->viaText()
->retry();
// Retry as voice call
$response = Msg91::otp()
->number('919876543210')
->viaVoice()
->retry();
// ✅ Correct - Template ID provided for India
$response = Msg91::otp()
->template('YOUR_DLT_TEMPLATE_ID') // Required for India
->number('919876543210') // Indian number (starts with 91)
->send();
// ❌ Will throw error - Template ID missing for Indian number
$response = Msg91::otp()
->number('919876543210') // Indian number
->send(); // Missing template() - will throw InvalidArgumentException