playSMS Forum

[howto] Testing playSMS with Kannel

Install

How to install Kannel for playSMS in Ubuntu:

sudo apt install kannel
sudo mkdir -p /var/log/kannel /var/run/kannel /var/spool/kannel/store
sudo chown -R kannel /var/log/kannel /var/run/kannel /var/spool/kannel/store
sudo usermod -a -G dialout kannel

Edit /etc/default/kannel to activate smsbox, smsbox is part of Kannel, the daemon that handles SMS in Kannel:

sudo sed -i 's/#START_SMSBOX/START_SMSBOX/' /etc/default/kannel

I don’t need wapbox so I disable it:

sudo sed -i 's/START_WAPBOX/#START_WAPBOX/' /etc/default/kannel

Backup original kannel.conf:

sudo cp /etc/kannel/kannel.conf /etc/kannel/kannel.conf.dist

Download example kannel.conf for testing purposes (for this article):

wget -c https://raw.githubusercontent.com/antonraharja/playSMS/master/contrib/kannel/kannel.conf
sudo cp kannel.conf /etc/kannel/
ls -l /etc/kannel/

Edit new /etc/kannel/kannel.conf and change passwords, parts with CHANGE_THIS on the line.

Restart Kannel:

/etc/init.d/kannel stop
/etc/init.d/kannel start

I waited about 2-3 seconds after stop before start, I don’t use restart.

New example kannel.conf for testing purposes pushed in github, here:

You can download and use it as your base and then modify it.

Using example kannel.conf above as-is for your Kannel will provide 2 SMSC, smpp1 and smpp2.

Configure

Next, configure Kannel gateway plugin in playSMS

Go to Settings -> Manage gateway and SMSC and click Manage (the folder icon) on Gateway Kannel. Fill in with data form kannel.conf:

If you see above on Bearerbox hostname or IP its an IP public, not 127.0.0.1 or localhost, this is because my playSMS is using HTTPS and a domain name, its not accessible through http://localhost. Therefore I need to set server’s IP address where requests from Kannel to playSMS logged as access from outside (read as remote IP with the same IP as the server accessing it self).

If you can access playSMS with http://localhost then Bearerbox hostname or IP should be 127.0.0.1 or localhost.

On Operational tab, fill in the correct admin password or status password, sets in kannel.conf:

You should see SMSC smpp1 and smpp2 are both online.

Tests

To route SMS to Kannel and those SMSC’s above you will need to add SMSC to playSMS, click the plus sign in Gateway Kannel in Settings -> Manage gateway and SMSC.

Add 2 SMSC to playSMS, first give name smpp1 and second give it name smpp2, example here:

Now we can route SMS for testing, go to Settings -> Route outgoing SMS:

References

See this article to give you understanding how playSMS handles gateway and SMSCs:

And perhaps googling you’ll find more example.

Example 1

Example kannel.conf for SMPP

For example, this is what I have

  • 1 server
    • Installed Ubuntu server 18.04
    • Installed playSMS 1.4.3 and latest Kannel from apt-get
    • Installation for playSMS 1.4.3 done following instructions in playsms.org
    • Installation for Kannel just like first post in this thread
    • playSMS and Kannel are on the same server
  • playSMS URL is accessible only from https://sms.example.com
    • Meaning when you browse it then it will show playSMS login box
    • Usually means cannot access playSMS from http://localhost (or https://localhost)
    • So that means Kannel option for get-url is https://sms.example.com/plugin/gateway/kannel/geturl.php
    • Or, this is the same, https://sms.example.com/index.php?app=call&cat=gateway&plugin=kannel&access=geturl
  • Provider give this for SMPP connection:
    • SMPP server host: sv78smpp.example.com
    • SMPP server port: 2715
    • SMPP username/system id: e1699
    • SMPP password: h239yf7n5csta6zg

Get example kannel.conf

Download and edit:
https://raw.githubusercontent.com/antonraharja/playSMS/master/contrib/kannel/kannel.conf

And this is my final example kannel.conf

## CORE

group = core
admin-password = siudfnhetwhf9jw4tyr23
status-password = 2orhf93euwfn29cbrnh
admin-port = 13000
admin-deny-ip = *.*.*.*
admin-allow-ip = 127.0.0.1
smsbox-interface = 127.0.0.1
smsbox-port = 13001
box-deny-ip = *.*.*.*
box-allow-ip = 127.0.0.1
log-file = /var/log/kannel/kannel.log
log-level = 0
access-log = /var/log/kannel/access.log
store-type = spool
store-location = /var/spool/kannel/store
smsbox-max-pending = 100

## SMSBOX

group = smsbox
smsbox-id = smsbox1
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-interface = 127.0.0.1
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox1.log
log-level = 0
access-log = /var/log/kannel/access.log

## SMSC

group = smsc
smsc-id = smpp1
smsc = smpp
host = sv78smpp.example.com
port = 2715
transceiver-mode = yes
smsc-username = e1699
smsc-password = h239yf7n5csta6zg
system-type = "VMA"
log-file = /var/log/kannel/smsc-smpp1.log
log-level = 0

## SMSBOX-ROUTE - Outgoing SMS route

group = smsbox-route
smsbox-id = smsbox1
smsc-id = smpp1

## SENDSMS-USER - Outgoing SMS

group = sendsms-user
default-smsc = none
username = playsms
password = j19293oik72e01h3k2ry
max-messages = 6
concatenation = true

## SMS SERVICE - Incoming SMS

group = sms-service
keyword = default
omit-empty = true
max-messages = 0
get-url = "https://sms.example.com/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i"

Example 2

Example kannel.conf for SMPP, playSMS accessible from localhost

For example, this is what I have

  • 1 server
    • Installed Ubuntu server 18.04
    • Installed playSMS 1.4.3 and latest Kannel from apt-get
    • Installation for playSMS 1.4.3 done following instructions in playsms.org
    • Installation for Kannel just like first post in this thread
    • playSMS and Kannel are on the same server
  • playSMS URL is accessible only from http://localhost/playsms
    • Meaning when you browse it then it will show playSMS login box
    • That means Kannel option for get-url is http://localhost/playsms/plugin/gateway/kannel/geturl.php
    • Or, this is the same, http://localhost/playsms/index.php?app=call&cat=gateway&plugin=kannel&access=geturl
  • Provider give this for SMPP connection:
    • SMPP server host: sv78smpp.example.com
    • SMPP server port: 2715
    • SMPP username/system id: e1699
    • SMPP password: h239yf7n5csta6zg

Get example kannel.conf

Download and edit:
https://raw.githubusercontent.com/antonraharja/playSMS/master/contrib/kannel/kannel.conf

And this is my final example kannel.conf

## CORE

group = core
admin-password = siudfnhetwhf9jw4tyr23
status-password = 2orhf93euwfn29cbrnh
admin-port = 13000
admin-deny-ip = *.*.*.*
admin-allow-ip = 127.0.0.1
smsbox-interface = 127.0.0.1
smsbox-port = 13001
box-deny-ip = *.*.*.*
box-allow-ip = 127.0.0.1
log-file = /var/log/kannel/kannel.log
log-level = 0
access-log = /var/log/kannel/access.log
store-type = spool
store-location = /var/spool/kannel/store
smsbox-max-pending = 100

## SMSBOX

group = smsbox
smsbox-id = smsbox1
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-interface = 127.0.0.1
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox1.log
log-level = 0
access-log = /var/log/kannel/access.log

## SMSC

group = smsc
smsc-id = smpp1
smsc = smpp
host = sv78smpp.example.com
port = 2715
transceiver-mode = yes
smsc-username = e1699
smsc-password = h239yf7n5csta6zg
system-type = "VMA"
log-file = /var/log/kannel/smsc-smpp1.log
log-level = 0

## SMSBOX-ROUTE - Outgoing SMS route

group = smsbox-route
smsbox-id = smsbox1
smsc-id = smpp1

## SENDSMS-USER - Outgoing SMS

group = sendsms-user
default-smsc = none
username = playsms
password = j19293oik72e01h3k2ry
max-messages = 6
concatenation = true

## SMS SERVICE - Incoming SMS

group = sms-service
keyword = default
omit-empty = true
max-messages = 0
get-url = "http://localhost/playsms/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i"