🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux s20058.bom1.stableserver.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
👤 User: skhata (1324)
🐘 PHP: 8.4.20
🚫 Disabled: ✨ NONE

💻 Terminal

📁 /home/skhata/chandrasons.com/public
$

📄 TwilioSmsChannel.php

📁 Path: /home/skhata/new.chandrapharma.com/app/Modules/Notification/Channels/TwilioSmsChannel.php
📊 Size: 1.4 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php

namespace App\Modules\Notification\Channels;

use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

/**
 * Twilio SMS Channel — India + International
 *
 * API: https://api.twilio.com/2010-04-01/Accounts/{SID}/Messages.json
 * Env: TWILIO_SID, TWILIO_AUTH_TOKEN, TWILIO_FROM
 *
 * Twilio is used when the destination number is NOT a Nepal number (+977).
 */
class TwilioSmsChannel
{
    public function send(string $to, string $message): bool
    {
        $sid   = config('notification.twilio.sid');
        $token = config('notification.twilio.auth_token');
        $from  = config('notification.twilio.from');

        if (! $sid || ! $token || ! $from) {
            Log::warning('Twilio: credentials not configured');
            return false;
        }

        $url = "https://api.twilio.com/2010-04-01/Accounts/{$sid}/Messages.json";

        $response = Http::withBasicAuth($sid, $token)
            ->asForm()
            ->post($url, [
                'From' => $from,
                'To'   => $to,
                'Body' => $message,
            ]);

        if (! $response->successful()) {
            Log::error('Twilio SMS send failed', [
                'to'       => $to,
                'response' => $response->json(),
            ]);
            return false;
        }

        Log::info('Twilio SMS sent', ['to' => $to, 'sid' => $response->json('sid')]);
        return true;
    }
}
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨