WARNING

This channel is deprecated. Please see the GitHub Repo (opens new window) for more information

# Gammu Notifications Channel for Laravel 5.3

Latest Version on Packagist (opens new window) Software License (opens new window) Build Status (opens new window) StyleCI (opens new window) SensioLabsInsight (opens new window) Quality Score (opens new window) Total Downloads (opens new window)

~This package makes it easy to send SMS notifications using Gammu SMSD (opens new window) with Laravel 5.3.~

# Channel Deprecated

Please see this issue (opens new window) for more infomation.
This channel was deprecated in Oct 2019 due to lack of a maintainer.

If you'd like to take over maintaince, feel free to open an PR to bring the package up to date & we can transfer the package.

# Contents

# Requirements

# Gammu

Make sure your Gammu SMSD has properly configured and able to send SMS. For more info to install and configure Gammu SMSD, read the Gammu SMSD documentation (opens new window).

# Gammu Api

This is optional if you want to use Gammu Api (opens new window). Make sure Gammu Api has properly configured and able to send SMS using this API.

Under the hood, Gammu Api is using gammu sendsms command line.

# Installation

You can install the package via composer:

composer require laravel-notification-channels/gammu

You must install the service provider:

// config/app.php
'providers' => [
    ...
    NotificationChannels\Gammu\GammuServiceProvider::class,
],

# Setting Up Gammu Service

There are two methods to send SMS using Gammu. First method is using native Gammu SMSD method, by inserting data directly to Gammu SMSD database. The second method is using Gammu Api.

# Using Native Gammu SMSD Method

Make sure your Gammu SMSD has properly configured and able to send SMS by inserting data to outbox table. The Gammu SMSD and database can be installed in the same machine or in different machine.

Add this settings in config/services.php to send SMS using native Gammu method.

...
'gammu' => [
    'method' => env('GAMMU_METHOD', 'db'),
    'sender' => env('GAMMU_SENDER', null),
],
...

Set the database setting to point Gammu SMSD database in config/database.php by adding this settings below.

// config/database.php
...
'connections' => [
    ...
    'gammu' => [
        'driver' => 'mysql',
        'host' => env('DB_GAMMU_HOST', 'localhost'),
        'port' => env('DB_GAMMU_PORT', '3306'),
        'database' => env('DB_GAMMU_DATABASE', 'forge'),
        'username' => env('DB_GAMMU_USERNAME', 'forge'),
        'password' => env('DB_GAMMU_PASSWORD', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],
    ...
],
...

The sender is the default sender name defined in phones table. If it's not set, it will automatically select the first data from phones table. This setting is useful if you have multiple sender.

# Using Gammu Api

Make sure your Gammu Api has properly configured and able to send SMS via it's API. The Gammu Api can be installed in the same machine or in different machine.

Add these settings in config/services.php to send SMS.

...
'gammu' => [
    'method' => env('GAMMU_METHOD', 'api'),
    'auth' => env('GAMMU_AUTH', 'gammu-api-key'),
    'url' => env('GAMMU_URL', 'http://gammu.api/')
],
...

# Using Gammu Api with Redis

Make sure, that your Redis server is running and it's able to communicate with your application and gammu api. You are also able to specify ->channel('name-channel') for using multiple Gammu Api's or have it on a non-default channel.

...
'gammu' => [
    'method' => env('GAMMU_METHOD', 'redis')
],
...

# Usage

You can now use the channel in your via() method inside the Notification class.

namespace App\Notifications;

use NotificationChannels\Gammu\GammuChannel;
use NotificationChannels\Gammu\GammuMessage;
use Illuminate\Notifications\Notification;

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

    public function toGammu($notifiable)
    {
        return (new GammuMessage())
            ->to($phoneNumber)
            ->content($content);
    }
}

If you have multiple senders, you can set the sender by passing sender method. If sender is not set, it will use one of sender from phones table. This method is only available if you're using native Gammu SMSD method.

public function toGammu($notifiable)
{
    return (new GammuMessage())
        ->to($phoneNumber)
        ->sender($sender)
        ->content($content);
}

# Routing a message

You can either send the notification by providing with the phone number of the recipient to the to($phoneNumber) method like shown in the above example or add a routeNotificationForGammu() method in your notifiable model.

...
/**
 * Route notifications for the Gammu channel.
 *
 * @return string
 */
public function routeNotificationForGammu()
{
    return $this->phone;
}
...

# Available methods

  • to($phoneNumber) : (string) Receiver phone number. Using international phone number (+62XXXXXXXXXX) format is highly suggested.
  • content($message) : (string) The SMS content. If content length is more than 160 characters, it will be sent as long SMS (opens new window) automatically.
  • sender($sender) : (string) Phone sender ID set in Gammu phones table. This method is only available if you're using native Gammu method.
  • callback($callbackText) : (string) Callback text for Gammu Api (opens new window) gives you function to pass text and when the Api will send your message it will be sent back to your callback url specified in your Gammu Api. Please setup callback properly on your Gammu Api.
  • channel($redisChannelName) : (string) Channel to publish to Redis. Default channel is gammu-channel.

# Changelog

Please see CHANGELOG (opens new window) for more information what has changed recently.

# Testing

$ composer test

# Security

If you discover any security related issues, please email halo@matriphe.com or kristian@rolmi.sk instead of using the issue tracker.

# Contributing

Please see CONTRIBUTING (opens new window) for details.

# Credits

# License

The MIT License (MIT). Please see License File (opens new window) for more information.