PHPackages                             tarfin-labs/netgsm - 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. tarfin-labs/netgsm

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

tarfin-labs/netgsm
==================

netgsm channel for laravel

5.1.0(5mo ago)4030.7k↓31.7%9[2 PRs](https://github.com/tarfin-labs/netgsm/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Feb 17Pushed 5mo ago5 watchersCompare

[ Source](https://github.com/tarfin-labs/netgsm)[ Packagist](https://packagist.org/packages/tarfin-labs/netgsm)[ Docs](https://github.com/tarfin-labs/netgsm)[ RSS](/packages/tarfin-labs-netgsm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (34)Used By (0)

[![Laravel Config Logo](https://camo.githubusercontent.com/9aaa4c1cf6e68a1188617c60d46bdd3982937593b90ab8ec89062cdef6694a90/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f6d656469612e74617266696e2e636f6d2f6173736574732f6c6f676f2d6e657467736d2e737667)](https://camo.githubusercontent.com/9aaa4c1cf6e68a1188617c60d46bdd3982937593b90ab8ec89062cdef6694a90/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f6d656469612e74617266696e2e636f6d2f6173736574732f6c6f676f2d6e657467736d2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b198b187e8c758adff5d24a808c0e84792f7146ee0625c8d4391617cb80a06a2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74617266696e2d6c6162732f6e657467736d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarfin-labs/netgsm)[![GitHub Workflow Status](https://camo.githubusercontent.com/7074680767253a411fcdc3b47505b98b209763488b892dedf48f00fa8181f1fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f74617266696e2d6c6162732f6e657467736d2f74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/7074680767253a411fcdc3b47505b98b209763488b892dedf48f00fa8181f1fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f74617266696e2d6c6162732f6e657467736d2f74657374733f6c6162656c3d7465737473)[![Quality Score](https://camo.githubusercontent.com/b75783540cbe9c08780d18d979bc260337ddc60904cafecd3d8fc368c0e32f4f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74617266696e2d6c6162732f6e657467736d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tarfin-labs/netgsm)[![Total Downloads](https://camo.githubusercontent.com/9962e92d43068452a65376e7e7ba3de97179674f00b53c545fc26cf780737d8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74617266696e2d6c6162732f6e657467736d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarfin-labs/netgsm)

Introduction
------------

[](#introduction)

With this package, you can send easily [Netgsm notifications](https://www.netgsm.com.tr/dokuman/#api-dok%C3%BCman%C4%B1) with Laravel `^8.0`. This package also provides some simple reporting.

> This package requires PHP `8.2` or higher and Laravel `11.0` or higher.
> For older versions of Laravel, please use version `^4.0.0` of this package!

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up the Netgsm service](#setting-up-the-Netgsm-service)
- [Usage](#usage)
    - [Service Methods](#service-methods)
    - [SMS Sending](#sms-sending)
        - [Available SMS Interfaces](#available-sms-interfaces)
    - [Reporting](#reporting)
        - [Available Reporting Interfaces](#available-report-interfaces)
    - [Account Balance](#account-balance)
        - [Remaining Balance](#remaining-balance)
        - [Remaining Package Credits](#remaining-package-credits)
    - [IYS Integration](#iys-integration)
        - [Add Address](#add-address)
        - [Search Address](#search-address)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require tarfin-labs/netgsm
```

Next, you should publish the Laravel config migration file using the vendor:publish Artisan command.

```
php artisan vendor:publish --provider="TarfinLabs\Netgsm\NetgsmServiceProvider"

```

### Setting up the Netgsm service

[](#setting-up-the-netgsm-service)

Add your Netgsm User Code, Default header (name or number of sender), and secret (password) to your `.env`:

```
// .env
...
NETGSM_USERCODE=
NETGSM_SECRET=
NETGSM_LANGUAGE=
NETGSM_HEADER=
NETGSM_BRANDCODE=
],
...
```

NETGSM\_USERCODE and NETGSM\_SECRET is authentication information of netgsm. NETGSM\_HEADER is default header (name or number of sender) of sms messages.

### Usage

[](#usage)

#### Service Methods

[](#service-methods)

```
 Netgsm::sendSms(AbstractSmsMessage $message):string $JobId
```

Sends an SMS message to the phone number on the message object passed as a parameter. If the message is sent successfully, a job id returned from the netgsm API service is returned.

```
Netgsm::getReports(AbstractNetgsmReport $report): ?Collection
```

Returns a collection based on the report object passed as a parameter.

#### Sms Sending with Using Notification Channel

[](#sms-sending-with-using-notification-channel)

In order to let your Notification know which phone number you are sending to, add the routeNotificationForNetgsm method to your Notifiable model e.g your User Model

```
public function routeNotificationForNetgsm()
{
    /*
       where `phone` is a field in your users table,
       phone number format can be either `5051234567` or `5051234567, 5441234568`.
    */
    return $this->phone;
}
```

You can use the channel in your `via()` method inside the notification:

```
use TarfinLabs\Netgsm\NetGsmChannel;
use TarfinLabs\Netgsm\NetGsmSmsMessage;
use Illuminate\Notifications\Notification;

class NewUserRegistered extends Notification
{
    public function via($notifiable)
    {
        return [NetGsmChannel::class];
    }

    public function toNetgsm($notifiable)
    {
        return (new NetGsmSmsMessage("Hello! Welcome to the club {$notifiable->name}!"));
    }
}
```

You can add recipients (string or array)

```
return (new NetGsmSmsMessage("Your {$notifiable->service} was ordered!"))->setRecipients($recipients);
```

You can also set the sending date range of the message. (It does not work on OTP messages.)

```
$startDate = Carbon::now()->addDay(10)->setTime(0, 0, 0);
$endDate = Carbon::now()->addDay(11)->setTime(0, 0, 0);

return (new NetGsmSmsMessage("Great note from the future!"))
->setStartDate($startDate)
->setEndDate($endDate)
```

You can set authorized data parameter (It does not work on OTP messages.)

If this parameter passes as true, only SMS will be sent to phone numbers that have data permission.

```
return (new NetGsmSmsMessage("Your {$notifiable->service} was ordered!"))->setAuthorizedData(true);
```

Additionally, you can change the header.

```
return (new NetGsmSmsMessage("Your {$notifiable->service} was ordered!"))->setHeader("COMPANY");
```

You can use NetGsmOtpMessage instead of NetGsmSmsMessage to send an OTP message.

```
return (new NetGsmOtpMessage("Your {$notifiable->service} OTP Token Is : {$notifiable->otp_token}"));
```

For more information on sending OTP messages [Netgsm OTP SMS Documentation](https://www.netgsm.com.tr/dokuman/#otp-sms)

#### Sms Sending with Using Netgsm Facade

[](#sms-sending-with-using-netgsm-facade)

You can also send SMS or OTP messages using Netgsm Facade directly:

```
$message = new NetgsmSmsMessage("Your {$notifiable->service} was ordered!");
->setHeader("COMPANY")
->setRecipients(['5051234567','5441234568']);

Netgsm::sendSms($message);
```

#### Reporting

[](#reporting)

You can get SMS reports by date range or netgsm bulk id.

To receive a report, a report object must be created.

```
$report = new NetgsmSmsReport();
```

##### Available Report Interfaces:

[](#available-report-interfaces)

- NetgsmSmsReport (basic reports): [Documentation](https://www.netgsm.com.tr/dokuman/#http-get-rapor)
- NetgsmSmsDetailReport (detailed reports) [Documentation](https://www.netgsm.com.tr/dokuman/#detayl%C4%B1-rapor)

##### Object Parameters

[](#object-parameters)

MethodDescriptionTypeRequiredNetgsmSmsReport SupportNetgsmSmsDetailReport SupportsetStartDate()Start DateCarbonNoYesYessetEndDate()End DateCarbonNoYesYessetBulkId()Netgsm Job IdIntegerNoYesYessetStatus()Message StatusIntegerNoYesNosetPhone()Phone NumberString\[\]NoYesYessetHeader()HeaderStringNoYesYessetVersion()API VersionIntegerNoYesYes##### Sample Usage

[](#sample-usage)

You can get the SMS report to passing the report object to the Netgsm::getReports method. If successful, SMS report results will be returned as a collection.

```
// Start and end dates
$startDate = Carbon::now()->subDay()->setTime(0, 0, 0);
$endDate = Carbon::now()->setTime(0, 0, 0);

$report = new NetgsmSmsReport();
$report->setStartDate($startDate)
    ->setEndDate($endDate);

$reports = Netgsm::getReports($report);
Netgsm::getReports($report);
```

Fields in the report result may differ depending on the specified report type and the report version parameter sent.

Report Results

FieldVersionNetgsmSmsReport SupportNetgsmSmsDetailReport SupportjobIdAllYesYesmessage1NoYesphoneAllYesNostatusAllYesYesoperatorCode2YesNolength2YesNostartDate2YesNostartTime2YesNoendDateAllNoYeserrorCode2YesNoheaderAllNoYestotalAllNoYes### Account Balance

[](#account-balance)

With this service, you can inquire the remaining balance of your netgsm account and the credit balances of your packages.

#### Remaining Balance

[](#remaining-balance)

Returns the remaining money balance on netgsm account. (TL)

Usage:

```
Netgsm::getCredit();
```

Output:

```
2,7
```

#### Remaining Package Credits

[](#remaining-package-credits)

Returns the credit balances of the packages defined in the relevant netgsm account.

Usage:

```
Netgsm::getAvailablePackages();
```

Output:

```
class Illuminate\Support\Collection#105 (1) {
  protected $items =>
  array(3) {
    [0] =>
    array(3) {
      'amount' =>
      int(1000)
      'amountType' =>
      string(14) "Adet Flash Sms"
      'packageType' =>
      string(0) ""
    }
    [1] =>
    array(3) {
      'amount' =>
      int(953)
      'amountType' =>
      string(12) "Adet OTP Sms"
      'packageType' =>
      string(0) ""
    }
    [2] =>
    array(3) {
      'amount' =>
      int(643)
      'amountType' =>
      string(4) "Adet"
      'packageType' =>
      string(3) "SMS"
    }
  }
}
```

### IYS Integration

[](#iys-integration)

With these services you can add and search any address to IYS.

#### Add Address

[](#add-address)

This service is used to add a phone number or email address to IYS using NetGsm IYS service.

##### Object Parameters

[](#object-parameters-1)

MethodDescriptionTypeRequiredsetRefId()Reference id to query your requestStringNosetType()Communication typeStringYessetSource()Source of permissionStringYessetRecipient()phone number or email addressStringYessetStatus()Permission statusStringYessetConsentDate()Permission dateDatetime (YYYY-MM-DD H:i:s)YessetRecipientType()Recipient typeStringYessetRetailerCode()Retailer codeIntegerNosetRetailerAccess()Retailer accessIntegerNo##### Usage

[](#usage-1)

```
$address = new \TarfinLabs\Netgsm\Iys\Requests\Add();
$address->setRefId(999999)
        ->setType('MESAJ')
        ->setSource('HS_WEB')
        ->setRecipient('+905XXXXXXXXX')
        ->setStatus('ONAY')
        ->setConsentDate(now()->toDateTimeString())
        ->setRecipientType('TACIR');

\TarfinLabs\Netgsm\Netgsm::iys()->addAddress($address)->send();
```

##### Response Parameters

[](#response-parameters)

```
{
    "code": "0",
    "error": "false",
    "uid": "73113cb9-dff0-415b-9491-xxxxxxxxxx"
}
```

#### Bulk Insert

[](#bulk-insert)

```
$address = new \TarfinLabs\Netgsm\Iys\Requests\Add();
$address->setRefId(999999)
        ->setSource('HS_WEB')
        ->setRecipient('+905XXXXXXXXX')
        ->setStatus('ONAY')
        ->setConsentDate(now()->toDateTimeString())
        ->setRecipientType('TACIR');

$iys = \TarfinLabs\Netgsm\Netgsm::iys();
$iys->addAddress($address->setType('MESAJ'));
$iys->addAddress($address->setType('ARAMA'));
$iys->send();
```

#### Response Paramaters for Bulk Insert

[](#response-paramaters-for-bulk-insert)

```
{
    "code": "0",
    "error": "false",
    "uid": "16116f5e-ae2a-4745-927a-xxxxxxxxxxx",
    "erroritem": {
        "1": {
            "recipient": "Telefon numarası 13 karakter ve numerik olmalıdır.+9xxxx"
        }
    }
}
```

#### Search Address

[](#search-address)

This service is used to search a phone number or email address on IYS using NetGsm IYS service.

##### Object Parameters

[](#object-parameters-2)

MethodDescriptionTypeRequiredsetType()Communication typeStringYes (if refId is set to null)setRecipient()phone number or email addressStringYes (if refId is set to null)setRecipientType()Recipient typeStringYes (if refId is set to null)setRefId()Reference id to query your requestStringNo##### Usage

[](#usage-2)

```
$address = new \TarfinLabs\Netgsm\Iys\Requests\Search();
$address->setType('MESAJ')
        ->setRecipient('+905XXXXXXXXX')
        ->setRecipientType('TACIR')
        ->setRefId(999999);

\TarfinLabs\Netgsm\Netgsm::iys()->searchAddress($address)->send();
```

##### Response Parameters

[](#response-parameters-1)

- Response with a matched address.

```
{
    "code": "0",
    "error": "false",
    "query": {
        "consentDate": "2020-11-06 11:22:34",
        "source": "HS_FIZIKSEL_ORTAM",
        "recipient": "+905XXXXXXXXX",
        "recipientType": "BIREYSEL",
        "type": "MESAJ",
        "status": "ONAY",
        "creationDate": "2020-11-06 11:23:49",
        "retailerAccessCount": 0
        // "querystatus": null
    }
}
```

- Response without any matched address

```
{
    "code": "50",
    "error": "Kayıt bulunamadi."
}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

### Security

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Hakan Özdemir](https://github.com/hozdemir)
- [Faruk Can](https://github.com/frkcn)
- [Yunus Emre Deligöz](https://github.com/deligoez)
- [Turan Karatuğ](https://github.com/tkaratug)
- [All Contributors](../../contributors)

### License

[](#license)

Laravel Netgsm is open-sourced software licensed under the MIT license.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance70

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~124 days

Recently: every ~253 days

Total

18

Last Release

175d ago

Major Versions

v1.x-dev → 2.0.02020-03-03

2.1.2 → 3.0.02020-10-06

3.0.1 → 4.0.02021-05-06

4.6.0 → 5.0.02025-02-24

PHP version history (8 changes)1.0.0PHP ^7.4

2.0.0PHP ^7.2

3.0.0PHP ^7.3

4.2.0PHP ^7.4 || ^8.0

4.3.0PHP ^7.4|^8.0|^8.1

4.5.0PHP ^7.4|^8.0|^8.1|^8.2

4.6.0PHP ^7.4|^8.0|^8.1|^8.2|^8.3

5.0.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/e252316490c5fc7bae7eb25b6c0cb301b49fbc706c32896fea9467b64cf3653b?d=identicon)[Tarfin Labs](/maintainers/Tarfin%20Labs)

---

Top Contributors

[![frkcn](https://avatars.githubusercontent.com/u/374634?v=4)](https://github.com/frkcn "frkcn (38 commits)")[![hozdemir](https://avatars.githubusercontent.com/u/464927?v=4)](https://github.com/hozdemir "hozdemir (34 commits)")[![tkaratug](https://avatars.githubusercontent.com/u/4394344?v=4)](https://github.com/tkaratug "tkaratug (22 commits)")[![takdeniz](https://avatars.githubusercontent.com/u/5904408?v=4)](https://github.com/takdeniz "takdeniz (8 commits)")[![YunusEmreNalbant](https://avatars.githubusercontent.com/u/29780061?v=4)](https://github.com/YunusEmreNalbant "YunusEmreNalbant (6 commits)")[![deligoez](https://avatars.githubusercontent.com/u/3030815?v=4)](https://github.com/deligoez "deligoez (5 commits)")[![oguzhankrcb](https://avatars.githubusercontent.com/u/7572058?v=4)](https://github.com/oguzhankrcb "oguzhankrcb (2 commits)")

---

Tags

laravelnetgsmnetgsm-smsphpsmstarfin-labsnetgsm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tarfin-labs-netgsm/health.svg)

```
[![Health](https://phpackages.com/badges/tarfin-labs-netgsm/health.svg)](https://phpackages.com/packages/tarfin-labs-netgsm)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[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)

PHPackages © 2026

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