PHPackages                             mesalution/laravel-mesms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. mesalution/laravel-mesms

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mesalution/laravel-mesms
========================

A simple laravel package that helps you send SMS though various service providers

v1.0.3(9mo ago)011[2 issues](https://github.com/mesalution/laravel-mesms/issues)MITPHPPHP ^8.2

Since Jul 25Pushed 9mo agoCompare

[ Source](https://github.com/mesalution/laravel-mesms)[ Packagist](https://packagist.org/packages/mesalution/laravel-mesms)[ RSS](/packages/mesalution-laravel-mesms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Mesalution - Laravel SMS
========================

[](#mesalution---laravel-sms)

[![Latest Version](https://camo.githubusercontent.com/6c7a9957cc4a2aeac71fe12195436e8bf8d3826ac2a238a33c510de20ca9966c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6d6573616c7574696f6e2f6c61726176656c2d6d65736d733f6c6162656c3d76657273696f6e26736f72743d73656d766572)](https://github.com/mesalution/laravel-mesms/releases)[![License](https://camo.githubusercontent.com/2a200532b27627d9d4cdf3f539188a8edec49a44d96f7d6085cd0369967229a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6573616c7574696f6e2f6c61726176656c2d6d65736d73)](LICENSE)

แพ็กเกจ Laravel สำหรับส่งและจัดการ OTP ผ่านผู้ให้บริการ SMS ได้หลายเจ้า รองรับการเปลี่ยน driver ได้ง่าย และรองรับการเขียน fake สำหรับการทดสอบ

Feature
-------

[](#feature)

- รองรับการขอ OTP / ยืนยัน OTP / ขอ OTP ซ้ำ
- สลับ driver ได้ตาม environment (เช่น Production ใช้ gateway จริง, Local ใช้ Fake)
- ออกแบบตามหลัก SOLID ใช้งานร่วมกับ Laravel ได้เต็มรูปแบบ
- รองรับการจัดการ error ผ่าน Exception เฉพาะทาง

---

Spec Requirement
----------------

[](#spec-requirement)

- PHP &gt;= 8.2
- Laravel &gt;= 10
- Support `Illuminate\Support\Facades\App`
- Recommend use with Laravel Service Container

Installation
------------

[](#installation)

```
composer require mesalution/laravel-mesms
```

Configuration
-------------

[](#configuration)

Publish the config:

```
php artisan vendor:publish --provider="Mesalution\LaravelMesms\SmsServiceProvider"
```

Edit `config/sms.php`:

```
return [
    'driver' => env('SMS_DRIVER', 'promotech'),
    'providers' => [
        'fake' => [
            'class' => \Mesalution\LaravelMesms\Providers\FakeSms::class,
            'options' => []
        ],
        'promotech' => [
            'class' => \Mesalution\LaravelMesms\Providers\Promotech::class,
            'options' => [
                'url' => env('PROMOTECH_URL', 'http://apisms.promotech.co.th'),
                'username' => env('PROMOTECH_USERNAME'),
                'password' => env('PROMOTECH_PASSWORD'),
                'otcId' => env('PROMOTECH_OTC_ID'),
                'senderName' => env('PROMOTECH_SENDER_NAME'),
            ],
        ]
    ]
];
```

Or config in `.env`

```
SMS_DRIVER=promotech
PROMOTECH_USERNAME={{username}}
PROMOTECH_PASSWORD={{password}}
PROMOTECH_OTC_ID={{otcId}}
PROMOTECH_SENDER_NAME={{senderName}}
```

Usage
-----

[](#usage)

Create instance from `app()` helper

```
use Mesalution\LaravelMesms\Sms;

$sms = app(Sms::class);

$otp = $sms->requestOTP('0812345678');

$sms->verifyOTP('otp-id-xxx', '123456');
$sms->resendOTP('otp-id-xxx');
```

Manual create instance

```
use Mesalution\LaravelMesms\Sms;

$options = [
    'username'=>'{{username}}',
    'password'=>'{{password}}',
    'otcId'=>'{{otcId}}',
    'senderName'=>'{{senderName}}',
];
$sms = new Sms('promotech',$options);

$otp = $sms->requestOTP('0812345678');

$sms->verifyOTP('otp-id-xxx', '123456');
$sms->resendOTP('otp-id-xxx');
```

Inject in controller

```
use Mesalution\LaravelMesms\Sms;

class ExampleController extends Controller
{
    public function __constructor(protected Sms $sms){}

    public function index()
    {
        $otp = $this->sms->requestOTP('0812345678');
        $this->sms->verifyOTP('otp-id-xxx', '123456');
        $this->sms->resendOTP('otp-id-xxx');
    }
}
```

How to implement new driver
---------------------------

[](#how-to-implement-new-driver)

Driver must be implement interface `Mesalution\LaravelMesms\Contract\Sms`

```
use Mesalution\LaravelMesms\Contracts\Sms;
use Mesalution\LaravelMesms\Data\Otp;

class MySmsDriver implements Sms
{
    public function requestOTP(string $mobile): Otp
    {
        // your logic
    }

    public function verifyOTP(string $otpId, string $otpCode): bool
    {
        // your logic
    }

    public function resendOTP(string $otpId): bool
    {
        // your logic
    }
}
```

Error Handler
-------------

[](#error-handler)

this package will throw exception :

- RequestOtpException
- VerifyOtpException
- ResendOtpException
- AuthException
- BadResponseException
- ClientException
- ConfirmedOtpException
- ConnectionException
- ExpiredOtpException
- ExternalException
- InternalException
- InvalidOtpException
- OtpException
- SmsException

You can use try-catch for handle:

```
try {
    $sms->verifyOTP('otp-id', '000000');
} catch (\Mesalution\LaravelMesms\Exceptions\VerifyOtpException $e) {
    // จัดการกรณี otp ผิด
}
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance56

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

291d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4e605435678ac04412bd48007e086e39b851937d764e9b9882927d63155293f?d=identicon)[playerarm123](/maintainers/playerarm123)

---

Top Contributors

[![playerarm123](https://avatars.githubusercontent.com/u/54016083?v=4)](https://github.com/playerarm123 "playerarm123 (10 commits)")

### Embed Badge

![Health badge](/badges/mesalution-laravel-mesms/health.svg)

```
[![Health](https://phpackages.com/badges/mesalution-laravel-mesms/health.svg)](https://phpackages.com/packages/mesalution-laravel-mesms)
```

###  Alternatives

[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
