Padding Leadng Zeroes in Destination Number

Padding Leadng Zeroes in Destination Number SearchSearch

NowSMS Support Forums » NowSMS Support - SMS Issues » Archive through August 10, 2011 » Padding Leadng Zeroes in Destination Number « Previous || Next »
Author Message
Mathew Mathachan
New member
Username: Mathewm

Post Number: 9
Registered: 04-2011
Posted on Wednesday, June 22, 2011 - 11:01 am:   


In the SMPP message, How do we send leading zeroes along with the destination number.

The message is submitted over HTTP in the format +911234567890

Presently in the SMPP message it is encoded as 911234567890 with the corresponding TON and NPI parameters.

However, what do we do to send the number as 00911234567890 in the SMPP message.

Thanks in advance

Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3296
Registered: 08-2008
Posted on Wednesday, June 22, 2011 - 05:13 pm:   

Hi Mathew,

That is unusual. The TON value indicates that the number is international format, so it is odd that an SMPP server would want you to use a 00 prefix instead.

There is currently no easy way to accomplish the type of number conversion that you are asking for.

We did recently make changes to the accounting callback interface that allow the accounting callback to change source and destination addresses when a message is submitted.

It's not easy, but it's not that difficult, to create an accounting callback script that looks for recipient addresses that start with +91 and changes them to start with 0091.

As an example, I created a PHP script that does just this.

I call it remap.php, and here it is:

header ("Content-Type: text/plain");

if (!strcasecmp ($_REQUEST['Type'], "SMSSend")) {
if (isset($_REQUEST['To'])) {
$to = $_REQUEST['To'];
if (!strncmp ($to, "+91", 3)) {
$to = "00" . substr($to, 1);
echo "To=" . $to . "\r\n";

Basically, this script is installed as a NowSMS accounting callback.

It parses the "Type=" input to make sure it is an "SMSSend" callback. It then looks at the "To=" (recipient) address, and if it starts with +91, it changes the + to 00 in its response back to NowSMS.

remap.php can be installed on a separate web server, or it can be installed directly on NowSMS and run under a local copy of PHP if you follow the instructions at

I tested the script by installing on a NowSMS server on my desktop. I installed PHP following the directions above.

I saved remap.php in the \ProgramData\NowSMS\PHP directory.

I then added the following statements to the [SMSGW] section of SMSGW.INI:


Then, restarted the NowSMS service.

The accounting script was called each time a message was submitted, and if the recipient started with +91, it was changed to start with 0091.

Again ... not easy ... but not extremely difficult.

NowSMS Support}