This package makes it easy to send notifications using sipgate with Laravel 5.5+, 6.x, 7.x, 8.x, 9.x.
Install the package via composer:
composer require laravel-notification-channels/sipgate
Extend config/services.php
to read your sipgate credentials from your .env
:
return [
...
'sipgate' => [
'username' => env('SIPGATE_USERNAME'),
'password' => env('SIPGATE_PASSWORD'),
'smsId' => env('SIPGATE_SMSID'),
'enabled' => env('SIPGATE_NOTIFICATIONS_ENABLED', true),
],
];
Add your sipgate credentials to your .env
:
SIPGATE_NOTIFICATIONS_ENABLED=true
SIPGATE_USERNAME=mail@example.com
SIPGATE_PASSWORD=1234567890
SIPGATE_SMSID=s0
A Web SMS extension consists of the letter 's' followed by a number (e.g. s0
). The sipgate API uses the concept of Web SMS extensions to identify devices within your account that are enabled to send SMS. In this context the term 'device' does not necessarily refer to a hardware phone but rather a virtual connection.
You can find out what your extension is as follows:
https://app.sipgate.com/{...}/connections/sms/{smsId}
where {smsId}
is your Web SMS extension.By default 'sipgate' will be used as the sender. It is only possible to change the sender to a mobile phone number by verifying ownership of said number. In order to accomplish this, proceed as follows:
When your credentials are configured, you can use the sipgate
channel in your notifications.
class ExampleNotification extends Notification
{
public function via($notifiable)
{
return ['sipgate'];
}
public function toSipgate($notifiable)
{
return SipgateMessage::create('Your message goes here…');
}
}
You can either choose to add the recipients number to the message itself:
public function toSipgate($notifiable)
{
return SipgateMessage::create('Your message goes here…')->recipient('00491234567890');
}
Or add a routeNotificationForSipgate
method to your notifiable class:
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForSipgate($notification)
{
return $this->phone_number;
}
}
If you define both, the message will be send to the number you defined in the message.
If you want to send a notification to someone who is not registered in your application, use on-demand notifications:
Notification::route('sipgate', '00491234567890')
->notify(new ExampleNotification($message));
public function toSipgate($notifiable)
{
return (new SipgateMessage('Your message goes here…'))
->message('…or here')
->recipient('00491234567890')
->sendAt(time() + 60)
->smsId('s0');
}
Optional: In order to send a delayed message set the desired date and time in the future (up to one month):
$message->sendAt(time() + 60);
Note: The
sendAt
method accepts a Unix timestamp.
Possible reasons are:
reason | errorcode |
---|---|
bad request (e.g. request body fields are empty or only contain spaces, timestamp is invalid etc.) | 400 |
username and/or password are wrong | 401 |
insufficient account balance | 402 |
no permission to use specified SMS extension (e.g. SMS feature not booked, user password must be reset in web app) | 403 |
internal server error or unhandled bad request (e.g. smsId not set) |
500 |
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email mail@simonkubiak.de instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.