A CLI application to send SMS from a database queue.
It uses Infobip api to send messages, thus requires you to supply a valid Infobip Username and Password.
Out of the box it works with Oracle database, but also supports:
- PostgresSQL
- MySQL
- Sql Server
- Sqlite
It can work with any database supported by a Laravel database driver.
git clone https://github.com/tumainimosha/sms-sender.git
Rename the .env.example
file to .env
Edit .env
file and substitute your credentials
# Infobip Credentials
INFOBIP_USERNAME=infobip-user
INFOBIP_PASSWORD=infobip-pass
INFOBIP_FROM="SENDER NAME"
# Database Credentials
DB_CONNECTION=oracle
DB_HOST=10.10.0.5
DB_PORT=1521
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_SERVICE_NAME=
# Maximum number of messages sent per script run
MAX_TAKE_RUN=100
# SMS table config
TABLE_OUTGOING_SMS=outgoing_sms
COLUMN_PRIMARY_KEY=id
COLUMN_MSISDN=msisdn
COLUMN_TEXT=text
COLUMN_SENDER=sender_name
COLUMN_SENT_AT=sent_at
-
This step requires you to have
php-7
andcomposer
installed on your machine -
Ensure your PHP installation has necessary database driver for database you are working with.
composer install
- Option 1: use the default table schema for messages
outgoing_sms | |
---|---|
id | PRIMARY_KEY |
msisdn | VARCHAR(255) |
text | TEXT |
sender_name | VARCHAR(255) |
sent_at | TIMESTAMP |
You can create this table yourself directly on your DB
OR
use the scripts migration to create it
php sms-sender migrate
- Option 2: use your own custom table schema for messages
If you choose to use different table name and columns from the ones specified above, edit the .env
file to specify the customizations you are using
# SMS table config
TABLE_OUTGOING_SMS=outgoing_sms
COLUMN_PRIMARY_KEY=id
COLUMN_MSISDN=msisdn
COLUMN_TEXT=text
COLUMN_SENDER=sender_name
COLUMN_SENT_AT=sent_at
$ php sms-sender process
Fetch pending messages from DB: ✔
Sending messages: ✔
You can schedule it using your OS's task schedule to run at given intervals, say once per minute.
It will fetch all pending messages at that time, send them, and update sent_at
column to time of sending the sms.
Run the tests with:
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.