Wednesday, February 11, 2009

kannel sms delivery report workout

1) Add one of the following options to core group of kannel configuration. If you use mysql as dlr-storage you have to configure two more groups to associate mysql with kannel. If you use dlr-storage=internal skip step 2. If you use dlr-storage=internal the data is not tangible according to my knowledge. Also keep in mind that there are other parameters for dlr-storage which we can use to connect with other databases like postgresql

dlr-storage = internal
dlr-storage = mysql

2) If you use mysql add following two groups to kannel.conf (or to separate file and include that file). Put your database username and password to the place of [db user] and [db passwd] . Group dlr-db uses to specify the table and map the feilds together. if you configure for mysql, the message will be temporarily stored in the table until it reaches the destination.

group = mysql-connection
id = mydlr
host = localhost
username = [db user]
password = [db passwd]
database = kannel
max-connections = 1

group = dlr-db
id = mydlr
table = dlr
field-smsc = smsc
field-timestamp = ts
field-destination = destination
field-source = source
field-service = service
field-url = url
field-mask = mask
field-status = status
field-boxc-id = boxc

Thats all for kannel.conf...

3) Now you have to introduce following extra parameters to your kannel send sms url


dlr-mask specifies the types of reports which kannel should generate. dlr-url specifies the url which will be called when the delivery report is received. For dlr-mask you can use one of the following mask numbers or any combination of them.

1: delivery success

2: delivery failure

4: message buffered

8: smsc submit

16: smsc reject

If you want multiple report types, you simply add the values together. For dlr-url you have to provide a url-encoded url for example
urlencoded url:

If you use php to interact with kannel you can easily generate urlencoded url using urlencode() function.

finally the resulting url is like this
http://localhost:13013/cgi-bin/sendsms?username=[kannel user]&password=[kannel passwd]&to=[to phone number]&text=[message text]&dlr-url=http%3A%2F%2Flocalhost%2Fsms%2Finc%2FdeliveryReport.php%3Fuser%3Djohn%26passwd%3D1234%26type%3D%25d%26receiver%3D%25p%26reply%3D%25A%26time%3D%25t%26usr%3D%25n%26message%3D%25b&dlr-mask=7

here I have used dlr-mask=7 so it will report following three types;
1: delivery success

2: delivery failure

4: message buffered


  1. Hi,

    Thanks for this article, found it very useful...

    So i need to create the MYSQL database to use this?>


  2. Hi Laxaman,

    As you mentioned in your blog I followed every step and I am able to submit to the SMSC and even getting the delivery response to the URL specified in the dlr-url. I have notice that delivery response not getting stored in the dlr table as specified in the kannel configuration under group = dlr-db. Can you please let me know whether the delivery response will get stored in the dlr table automatically by kannel or else we need to store it manually using PHP or JAVA.

  3. The dlr table is a temporary table used by Kannel to store dlr data for the message for which it hasn't received delivery status. If you want to check the statuses, you should use dlr-url and dlr-mask in that purpose

  4. hey ur post is good,
    please tell me how do i create dlr.php script? where shuld i stored it ? how to launch it? And if possible could u send me dlr.php script?
    here is my mail-id

    Sorry for silly qusetions?
    please help me?

  5. Hi,

    Thanks for the pointers :)
    Your article helped me lot.

  6. Great Sharing. What will come in this PHP file?


  7. Hello laxaman.. i got this article very much useful for me.Thanks ..
    And please help me to understand the proper working of kannel .. and if i use "dlr-storage = mysql" then it show unable to start kannel services :( ..
    Please help me to get resolve this issue.