Kannel is a compact and very powerful open source WAP and SMS gateway, used widely across the globe both for serving trillions of short messages (SMS), WAP Push service indications and mobile internet connectivity.
Visit the Kannel.org website and download the latest and greatest gateway-1.X.Y.tar.gz file.
From there Write the following commands:
mkdir src
cd src
tar xfz ../downloads/gateway-1.4.1.tar.gz
cd gateway-1.4.1
./configure --prefix=/usr/local/kannel
Compile and install by using the commands
make
sudo make install
Configuration is divided into a few key groups, each representing the key parts of the kannel system, including the server that handles sending and receving the actual SMSes (bearerbox) and the system that handles the final dispatching to your scripts (smsbox).
The core Group
The first part of the file is the “core” group, and the default is pretty close to what we want:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
log-file = "/tmp/kannel.log"
log-level = 0
box-deny-ip = "..."
box-allow-ip = "127.0.0.1"
The smsc Group
Kannel supports a pretty insane number of ways of sending and receiving SMSes, ranging from SMS services over HTTP, to a fake SMS centre for testing/development purposes, to GSM modems etc.
group = smsc
smsc = at
modemtype = auto
device=/dev/ttyS0
my-number = 123123123123
connect-allow-ip = 127.0.0.1
log-level = 0
The smsbox Group
The smsbox group helps configure the part of the system that dispatches SMSes received by the core SMS or receives SMSes before they’re sent out. I honestly don’t fully understand what this group really does, but it’s necessary, and pretty trivial to set up.
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = 123123123123
log-level = 0
The Sendsms Group
This group is what allows your web applications to send SMS messages using Kannel. They do this via simple HTTP requests, and configuration here basically requires a user name and password:
group = sendsms-user
username = kanneluser
password = df89asj89I23hvcxSDasdf3298jvkjc839
concatenation= true
max-messages = 10
Getting the Messages to your application
The sms-service group configures how Kannel gets messages to your web application. You are allowed to specify a number of these groups, each of which can “catch” incoming messages based on various criteria. My application had all messages go to one processing script, so I just set up one group that caught all incoming messages.
group = sms-service
keyword =
keyword-regex = .*
catch-all = yes
max-messages = 0
get-url = "http://localhost/sms?phone=%p&text=%a"
Running the Server
The hard part is done; all we have to do now is copy over the config files and start the service up by using the following commands:
cd /usr/local/kannel
cp ~/src/gateway-1.4.1/smskannel.conf .
cp ~/src/gateway-1.4.1/gw/modems.conf .
sbin/bearerbox -v 0 smskannel.conf &
sbin/smsbox -v 0 smskannel.conf &
To test the fake the gateway we can use a fake sms service. Go to the gateway directory and type the following command
test/fakesmsc -i 0.01 -v 1 -m 1000 "100 300 text echothis message"