~ Article by ~
Syed Jahanzaib
DMASOFTLAB Radius Manager has a very nice feature of SMS notification for Before Account Expiry SMS / Email , New Account Activation Message, New Account Activation Verification Code / Password Recovery and many other cool functions that can be done using this feature, however activating it is a bit complex thing to do. As radius manager supplies clickatell HTTP gateway API with there default installation, and I really didn’t wanted to purchase the clickatell account because it would be expensive for any mid-large size network, even a small network wouldn’t want to pay extra amount. So I decided to create my own HTTP gateway which is connected with my GSM Modem. Following is the complete guide on how you can create your own SMS HTTP GATEWAY.
Once you have a working HTTP gateway , you can move on to RM configuration section.
Howto configure API to make it work with your KANNEL SMS HTTP gateway.
Login to your RM box using terminal.
For Rm 4.1.x ONLY ! Open the smsgateway.php file by
nano /var/www/radiusmanager/api/smsgateway.php
Now remove all lines and replace them with the following.
<?php /***************************************************************************** ** This script is provided by DMASOFTLAB RM. ** Modified by Syed Jahanzaib / https://aacable.wordpress.com / aacable@hotmail.com ** I am using KANNEL as GATEWAY with 10-sec delay via this PHP CODE ** First Modified: Somwhere-2013 *****************************************************************************/ function sendsms($recp, $body, &$errmsg) { // enter your LOCAL HTTP SMS GATEWAY here $api_user = "kannel"; $api_password = "KANNEL-PASSWORD"; // clean up HTML entities $body = html_entity_decode($body, ENT_COMPAT, "UTF-8"); // implement your own SMS gateway here $body = rawurlencode($body); $ch = curl_init(); // change the IP and id password in the below line to match your local config. syed jahanzaib curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:13013/cgi-bin/sendsms?user=$api_user&password=$api_password&to=$recp&text=$body"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($ch); curl_close($ch); // uncomment the following line to see the result from the SMS gateway // print $res; // log result if (substr($res, 0 , 4) == "ERR:") $res_str = $res; else $res_str = "OK"; syslog(LOG_INFO, "[radiusmanager] Sending SMS with 10 sec delay in each SMS added by Syed_Jahanzaib to Mobile No " . $recp . " (" . $res_str . ")"); // Adding 10 seconds delay so that oru mobile SIM may not get blocked sleep(10); // error has occured, return FALSE if (substr($res, 0 , 4) == "ERR:") { $errmsg = $res; return false; } // no error, return TRUE return true; } ?>
That’s It. Your RM is ready to send sms using your local SMS HTTP gateway. Just make sure you enable sms for various events as described in RM ACP > Home Settings.
Howto send Account Expiry Warning to User via email/sms
Logon to RM Admin Panel,
Goto System/ System Settings
At the bottom of the page, You will see Notification’s section.
At the Expiry warning: Type the number of days you want RM to send account expiry warning before the account expires.
Also tick on all related options as showed in the image.
As showed in the image below . . .
Once the account reaches near its expiry, user will receive email like below . . .
Howto Recover User Password via FORGOT PASSWORD link at user.php (ver 4.x or above)
User can recover his forgotten password using Forgot my password at user.php
For Example
After submission the mobile number, user will receive A code on his mobile number (If he have defined valid number while registering the account. Then after entering the code in the below screen, he will receive new password.
As showed in the image below . . .
Howto change SMS templates (text)
You can edit the messages sent to users by modifying following files in
/var/www/radiusmanager/lang/English
Files are:
smsaccverify_tpl.txt smspswact_tpl.txt smspsw_tpl.txt smsselfregact_tpl.txt smswarnexp_tpl.txt smswarntraff_tpl.txt smswelcomeuser_tpl.txt
# Additional BASH Script to send General Announcement SMS to ACTIVE users only using local KANNEL sms gateway (who have mobile number mentioned)
#!/usr/bin/env bash ####!/bin/sh #set -x #trap "set +x; set -x" DEBUG # BASH base script to send sms to users from radius who are active and with mobile nos # the simple logic can be applied for about any other task as well. I tried to make it as simple as it can be # By Syed Jahanzaib # CREATED on : 16th July, 2015 # Modified on 25h June 2018 # Local Variables # Mysql credentials SQLID="root" SQLPASS="SQLROOTPASS" export MYSQL_PWD=$SQLPASS CMD="mysql -u$SQLID --skip-column-names -s -e" COMPANY="ZAIB" DB="radius" #Table which contain main users information TBL="rm_users" # Date Time Variables FULL_DATE=`date` TODAY=$(date +"%Y-%m-%d") # Kannel Server IP, if its local leave it as it is KURL="http://127.0.0.1:13013" KID="kannel" KPASS="KANNELPASS" ################################################## # Temp folder and files setup for various actions ################################################## ALLACTIVEUSERSLIST_TMP=/tmp/all_active_users_list_4_sms_tmp.txt ALLACTIVEUSERSLIST_FINAL=/tmp/all_active_users_list_4_sms_final.txt > $ALLACTIVEUSERSLIST_TMP > $ALLACTIVEUSERSLIST_FINAL ############################ ###### START thE script cOdE ############################ # Pull users that are ACTIVE only $CMD "use $DB; SELECT SQL_CALC_FOUND_ROWS username, firstname, lastname, address, city, zip, country, state, phone, mobile, email, company, taxid, srvid, downlimit, uplimit, comblimit, expiration, uptimelimit, credits, comment, enableuser, staticipcpe, staticipcm, ipmodecpe, ipmodecm, srvname, limitdl, limitul, limitcomb, limitexpiration, limituptime, createdon, verifycode, verified, selfreg, acctype, maccm, LEFT(lastlogoff, 10) , IF (limitdl = 1, downlimit - COALESCE((SELECT SUM(acctoutputoctets) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(dlbytes), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username), 0), 0), IF (limitul = 1, uplimit - COALESCE((SELECT SUM(acctinputoctets) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(ulbytes), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username), 0), 0), IF (limitcomb =1, comblimit - COALESCE((SELECT SUM(acctinputoctets + acctoutputoctets) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(ulbytes + dlbytes), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username), 0), 0), IF (limituptime = 1, uptimelimit - COALESCE((SELECT SUM(acctsessiontime) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(acctsessiontime), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username), 0), 0) FROM ( SELECT username, firstname, lastname, address, city, zip, country, state, phone, mobile, email, company, taxid, rm_users.srvid, rm_users.downlimit, rm_users.uplimit, rm_users.comblimit, rm_users.expiration, rm_users.uptimelimit, credits, comment, enableuser, staticipcpe, staticipcm, ipmodecpe, ipmodecm, srvname, limitdl, limitul, limitcomb, limitexpiration, limituptime, createdon, verifycode, verified, selfreg, acctype, maccm, mac, groupid, contractid, contractvalid, rm_users.owner, srvtype, lastlogoff FROM rm_users JOIN rm_services USING (srvid) ORDER BY username ASC ) AS tmp WHERE 1 AND (tmp.acctype = '0' OR tmp.acctype = '1' OR tmp.acctype = '2' OR tmp.acctype = '3' OR tmp.acctype = '4' OR tmp.acctype = '5' OR tmp.acctype = '6' ) AND tmp.enableuser = 1 AND (limitdl = 0 OR IF (limitdl =1, downlimit - (SELECT COALESCE(SUM(acctoutputoctets), 0) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(dlbytes), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username) , 1) > 0) AND (limitul = 0 OR IF (limitul =1, uplimit - (SELECT COALESCE(SUM(acctinputoctets), 0) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(ulbytes ), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username) , 1) > 0) AND (limitcomb = 0 OR IF (limitcomb =1, comblimit - (SELECT COALESCE(SUM(acctinputoctets + acctoutputoctets), 0) FROM radacct WHERE radacct.username = tmp.username) + (SELECT COALESCE(SUM(ulbytes + dlbytes), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username) , 1) > 0) AND (limituptime = 0 OR IF (limituptime=1, uptimelimit - (SELECT COALESCE(SUM(acctsessiontime), 0) FROM radacct WHERE radacct.username = tmp.username) - (SELECT COALESCE(SUM(acctsessiontime), 0) FROM rm_radacct WHERE rm_radacct.username = tmp.username) , 1) > 0) AND (limitexpiration = 0 OR IF (limitexpiration=1, UNIX_TIMESTAMP(expiration) - UNIX_TIMESTAMP(NOW()), 1) > 0) LIMIT 0, 5000;" | awk '{print $1}' |sort > $ALLACTIVEUSERSLIST_TMP #$CMD "use $DB; select username from $TBL where expiration ='$DAYS3';" |sort > $ALLACTIVEUSERSLIST_TMP # IF no user found , show error and exit - zaib CHK=`wc -m $ALLACTIVEUSERSLIST_TMP | awk {'print $1}'` if [ "$CHK" -eq 0 ] then echo "No active user found , exiting ..." exit 1 fi ACT_TOTAL=`cat $ALLACTIVEUSERSLIST_TMP | wc -l` echo "- Total Number of ACTIVE users : $ACT_TOTAL" echo "- Now sending sms to users ..." #sleep 10 # Apply formula num=0 cat $ALLACTIVEUSERSLIST_TMP |while read data do num=$[$num+1] USERNAME=`echo $data` MOBILE=`$CMD "use $DB; select mobile from $TBL where username='$USERNAME';" | sed -e 's/-//g'` FULLNAME=`$CMD "use $DB; select firstname,lastname from $TBL where username='$USERNAME';"` # IF user have NO mobile number ignore it if [ -z "$MOBILE" ]; then echo "$USERNAME does not have mobile number associated therefore no need to to send sms" else ##################### #### SEND SMS MESSAGE #### ##################### echo "$COMPANY Internet Alert:: International Bandwidth Submarine Cable Outage Notification. In addition to the trailing outage, we are observing outage on another International Submarine Cable. Internet speed Degradation. We are in follow up with authorities & further updates will be shared accordingly. Customer Care " > /tmp/$USERNAME.announce.sms echo $USERNAME / $MOBILE >> $ALLACTIVEUSERSLIST_FINAL cat /tmp/$USERNAME.announce.sms # Send SMS Alert via KANNEL curl "$KURL/cgi-bin/sendsms?username=$KID&password=$KPASS&to=$MOBILE" -G --data-urlencode text@/tmp/$USERNAME.announce.sms echo "ANNOUNCE SMS Sent to ID: $USERNAME - $FULLNAME $MOBILE , waiting 10 seconds for another SMS ... [TO AVOID SIM BLOCKING]" logger ANNOUNCE SMS Sent to ID: $USERNAME - $FULLNAME $MOBILE , waiting 10 seconds for another SMS ... TO AVOID SIM BLOCKING rm /tmp/$USERNAME.announce.sms fi echo "*********** Sleeping for 10 seconds to avoid sim blocking dueto bulk sms ... ************" sleep 10 done TOT_FINAL_NO=`cat $ALLACTIVEUSERSLIST_FINAL | wc -l` echo "Total Number of users to whom SMS was sent = $TOT_FINAL_NO"
Regard’s
Syed Jahanzaib
sir g aap ne maire mail ka jiwab nihe deya ? 😦
LikeLike
Comment by Rashid ali — November 26, 2012 @ 6:09 PM
regarding?
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — November 27, 2012 @ 12:15 PM
[…] DMASOFTLAB Radius Manager SMS Notification Configuration […]
LikeLike
Pingback by Howto setup Mini ISP using Mikrotik as PPPoE Server + DMASOFTLAB Radius Manager Scratch Card Billing System+ Linux Transparent Firewall Bridge + Ubuntu SQUID 2.7 Proxy Server « Syed Jahanzaib Personnel Blog to Share Knowledge ! — November 29, 2012 @ 3:11 PM
hello K can u tell me how to send more than one message in same time
LikeLike
Comment by the massage not resive to all custumer how expired in DMA-Radius manager — March 27, 2014 @ 7:14 PM
Hello, how I could do to make me not generate a new password, only send me the present password. It’s possible?
LikeLike
Comment by Wuilliams A. Hernandez — May 29, 2016 @ 4:23 AM
You have to make a Customized PHP page, where user can enter his USER ID, then script will check the user original password, and will send email or sms to his registered mobile number or email. customized script can be made on charges basis if you interested.
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — May 29, 2016 @ 4:27 PM
Yes, i’m interested.
LikeLike
Comment by Wuilliams A. Hernandez — May 30, 2016 @ 4:28 AM
Hello, how I could do to make me not generate a new password, but send me the present password. It’s possible?
LikeLike
Comment by Wuilliams A. Hernandez — May 29, 2016 @ 4:28 AM
Please I keep getting this error, is there something am not doing right.
thank you
3: Queued for later delivery
These are my configuration files:
group = smsc
smsc = at
modemtype = huawei
device = /dev/ttyUSB0
speed = 19200
my-number = 0207539902
sms-center = 00923040000011
validityperiod = 167
group = modems
id = huawei
name = “huawei k3565”
detect-string = “k3565”
init-string = “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
speed = 115200
group = smsbox
bearerbox-host = 192.168.1.100
sendsms-port = 13013
global-sender = 13013
sendsms-chars = “0123456789 +-”
log-file = “/var/log/kannel/smsbox.log”
log-level = 0
access-log = “/var/log/kannel/access.log”
group = sendsms-user
username = kannel
password = kannel
concatenation = true
max-messages = 3
group = sms-service
keyword = default
get-url = “http://192.168.1.100/kannel/receivesms.php?sender=%p&text=%b”
accept-x-kannel-headers = true
max-messages = 3
concatenation = true
catch-all = true
LikeLike
Comment by RichK — June 15, 2016 @ 7:12 AM
Queued for later delivery means kannel have configuration issue, either with the modem or the kannel itself. make sure modem is configured properly and is interacting with the kannel/
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — June 15, 2016 @ 10:16 AM
Hi, I”m new to all of this, I got the RM 30 trail and my idea is to connect it to MK and let users authenticate them self with SMS via hotspot, how I do that? and is there a splash page that in the RM that the Mikrotik redirect it to do the SMS authentication?
LikeLike
Comment by majedalanni — August 9, 2016 @ 8:04 PM
well it requires some consideration before going further.
its better if you send me an email with all the details and requirements so that i can suggest you better solutions. ,my email is
aacable at hotmail dot com
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — August 11, 2016 @ 10:54 AM
I want to use smsgateway.me with android phone for sms notification how can i do that? can you give me some hints. i will be very thank full to you.
LikeLike
Comment by Praveen — August 12, 2016 @ 12:47 PM
i want to send Arabic sms
LikeLike
Comment by jalal — August 28, 2016 @ 10:39 PM
Recently trying to change state and SMS getaway but when I refreshing RM ACP it’s not showing state which one I changed and SMS API also not work every time show error like “error 108, invalid or messing SMS API ” please any suggestions for me please reply fast I have 30 trails version only.
LikeLike
Comment by RAHUL GAMIT — September 18, 2017 @ 7:40 AM
hello sir h r u i like ur post very much …i am some confused tell me plz sms send automatically or personally send to groups on expiry??
LikeLike
Comment by waqar — October 26, 2017 @ 11:16 PM
how to change dma timing for sending sms alert of non payment reminder
LikeLike
Comment by Sajawal — November 2, 2018 @ 4:04 AM
You cannot modify it, its hardcoded in encrypted php code.
what you can do is to create your own script, that can fetch users that are expiring today (or whatever criteria you want) and schedule this script to run at your given time in cron). simple is this.
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — November 5, 2018 @ 8:10 AM
Hi, i set sms gateway and it is working, my problem is someting with radiusmanager, what ever i do, i get ERR: 108, Invalid or missing api_id, how to fix this?
LikeLike
Comment by Aleksandar Jezdic — February 10, 2020 @ 6:43 PM
is kannel installed on the same box of radius manager?
LikeLike
Comment by caci99 — May 1, 2020 @ 12:01 PM
yes.
but its not necessary. you can install kannel on separate box, as it supports http api for sending sms, so you can send sms from about any device either windows , linux, mikrotik via kannel box using different method, via browser, or via cmd using tools
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — May 1, 2020 @ 5:09 PM
Please am done installing KANNEL SMS gateway and everything is working perfectly well but can you help me change the SIM number for sending sms to my hotspot name?
LikeLike
Comment by richmmond — May 12, 2020 @ 1:09 AM