Smpp library in php

smpp

Hello friends,

If you have a smpp account you can simple send sms / unicode to any number using php. It is very simple .

Sample code is:

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
require_once('smppclass.php');
$smpphost = "203.199.142.41"; // your host address
$smppport = 2345;
$systemid = "idsfds"; // Your system id
$password = "es223"; // Your smpp account password
$system_type = "Rdsd "; // Your userid
$from = "919846341106"; // From number
$smpp = new SMPPClass();
$smpp->SetSender($from);
/* bind to smpp server */
$smpp->Start($smpphost, $smppport, $systemid, $password, $system_type);
/* send enquire link PDU to smpp server */
$smpp->TestLink();
/* send single message; large messages are automatically split */
$smpp->Send("971532663061", "This is a test message. Give me a missed call if you get this. sajith");
/* send unicode message */
//$smpp->Send("31648072766", "صباحالخير", true);
/* send message to multiple recipients at once */
//$smpp->SendMulti("31648072766,31651931985", "This is my PHP message");
/* unbind from smpp server */
$smpp->End();
//Click read more for smppclass.php library
More...
//file smppclass.php
define(CM_BIND_TRANSMITTER, 0x00000002);
define(CM_SUBMIT_SM, 0x00000004);
define(CM_SUBMIT_MULTI, 0x00000021);
define(CM_UNBIND, 0x00000006);
define(CM_ENQUIRELINK, 0x00000015);
class SMPPClass {
// public members:
/*
Constructor.
Parameters:
none.
Example:
$smpp = new SMPPClass();
*/
function SMPPClass()
{
/* seed random generator */
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
/* initialize member variables */
$this->_debug = true; /* set this to false if you want to suppress debug output. */
$this->_socket = NULL;
$this->_command_status = 0;
$this->_sequence_number = 1;
$this->_source_address = "";
$this->_message_sequence = rand(1,255);
}
/*
For SMS gateways that support sender-ID branding, the method
can be used to set the originating address.
Parameters:
$from : Originating address
Example:
$smpp->SetSender("31495595392");
*/
function SetSender($from)
{
if (strlen($from) > 20) {
$this->debug("Error: sender id too long.\n");
return;
}
$this->_source_address = $from;
}
/*
This method initiates an SMPP session.
It is to be called BEFORE using the Send() method.
Parameters:
$host : SMPP ip to connect to.
$port : port # to connect to.
$username : SMPP system ID
$password : SMPP passord.
$system_type : SMPP System type
Returns:
true if successful, otherwise false
Example:
$smpp->Start("smpp.chimit.nl", 2345, "chimit", "my_password", "client01");
*/
function Start($host, $port, $username, $password, $system_type)
{
/*
$testarr = stream_get_transports();
$have_tcp = false;
reset($testarr);
while (list(, $transport) = each($testarr)) {
if ($transport == "tcpp") {
$have_tcp = true;
}
}
if (!$have_tcp) {
$this->debug("No TCP support in this version of PHP.\n");
return false;
}
*/
$this->_socket = fsockopen($host, $port, $errno, $errstr, 20);
// todo: sanity check on input parameters
if (!$this->_socket) {
$this->debug("Error opening SMPP session.\n");
$this->debug("Error was: $errstr.\n");
return;
}
socket_set_timeout($this->_socket, 1200);
$status = $this->SendBindTransmitter($username, $password, $system_type);
if ($status != 0) {
$this->debug("Error binding to SMPP server. Invalid credentials?\n");
}
return ($status == 0);
}
/*
This method sends out one SMS message.
Parameters:
$to : destination address.
$text : text of message to send.
$unicode: Optional. Indicates if input string is html encoded unicode.
Returns:
true if messages sent successfull, otherwise false.
Example:
$smpp->Send("31649072766", "This is an SMPP Test message.");
$smpp->Send("31648072766", "صباحالخير", true);
*/
function Send($to, $text, $unicode = false)
{
if (strlen($to) > 20) {
$this->debug("to-address too long.\n");
return;
}
if (!$this->_socket) {
$this->debug("Not connected, while trying to send SUBMIT_SM.\n");
// return;
}
$service_type = "";
//default source TON and NPI for international sender
$source_addr_ton = 1;
$source_addr_npi = 1;
$source_addr = $this->_source_address;
if (preg_match('/\D/', $source_addr)) //alphanumeric sender
{
$source_addr_ton = 5;
$source_addr_npi = 0;
}
elseif (strlen($source_addr) < 11) //national or shortcode sender
{
$source_addr_ton = 2;
$source_addr_npi = 1;
}
$dest_addr_ton = 1;
$dest_addr_npi = 1;
$destination_addr = $to;
$esm_class = 3;
$protocol_id = 0;
$priority_flag = 0;
$schedule_delivery_time = "";
$validity_period = "";
$registered_delivery_flag = 0;
$replace_if_present_flag = 0;
$data_coding = 241;
$sm_default_msg_id = 0;
if ($unicode) {
$text = mb_convert_encoding($text, "UCS-2BE", "HTML-ENTITIES"); /* UCS-2BE */
$data_coding = 8; /* UCS2 */
$multi = $this->split_message_unicode($text);
}
else {
$multi = $this->split_message($text);
}
$multiple = (count($multi) > 1);
if ($multiple) {
$esm_class += 0x00000040;
}
$result = true;
reset($multi);
while (list(, $part) = each($multi)) {
$short_message = $part;
$sm_length = strlen($short_message);
$status = $this->SendSubmitSM($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_addr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message);
if ($status != 0) {
$this->debug("SMPP server returned error $status.\n");
$result = false;
}
}
return $result;
}
/*
This method ends a SMPP session.
Parameters:
none
Returns:
true if successful, otherwise false
Example: $smpp->End();
*/
function End()
{
if (!$this->_socket) {
// not connected
return;
}
$status = $this->SendUnbind();
if ($status != 0) {
$this->debug("SMPP Server returned error $status.\n");
}
fclose($this->_socket);
$this->_socket = NULL;
return ($status == 0);
}
/*
This method sends an enquire_link PDU to the server and waits for a response.
Parameters:
none
Returns:
true if successfull, otherwise false.
Example: $smpp->TestLink()
*/
function TestLink()
{
$pdu = "";
$status = $this->SendPDU(CM_ENQUIRELINK, $pdu);
return ($status == 0);
}
/*
This method sends a single message to a comma separated list of phone numbers.
There is no limit to the number of messages to send.
Parameters:
$tolist : comma seperated list of phone numbers
$text : text of message to send
$unicode: Optional. Indicates if input string is html encoded unicode string.
Returns:
true if messages received by smpp server, otherwise false.
Example:
$smpp->SendMulti("31777110204,31649072766,...,...", "This is an SMPP Test message.");
*/
function SendMulti($tolist, $text, $unicode = false)
{
if (!$this->_socket) {
$this->debug("Not connected, while trying to send SUBMIT_MULTI.\n");
// return;
}
$service_type = "";
$source_addr = $this->_source_address;
//default source TON and NPI for international sender
$source_addr_ton = 1;
$source_addr_npi = 1;
$source_addr = $this->_source_address;
if (preg_match('/\D/', $source_addr)) //alphanumeric sender
{
$source_addr_ton = 5;
$source_addr_npi = 0;
}
elseif (strlen($source_addr) < 11) //national or shortcode sender
{
$source_addr_ton = 2;
$source_addr_npi = 1;
}
$dest_addr_ton = 1;
$dest_addr_npi = 1;
$destination_arr = explode(",", $tolist);
$esm_class = 3;
$protocol_id = 0;
$priority_flag = 0;
$schedule_delivery_time = "";
$validity_period = "";
$registered_delivery_flag = 0;
$replace_if_present_flag = 0;
$data_coding = 241;
$sm_default_msg_id = 0;
if ($unicode) {
$text = mb_convert_encoding($text, "UCS-2BE", "HTML-ENTITIES");
$data_coding = 8; /* UCS2 */
$multi = $this->split_message_unicode($text);
}
else {
$multi = $this->split_message($text);
}
$multiple = (count($multi) > 1);
if ($multiple) {
$esm_class += 0x00000040;
}
$result = true;
reset($multi);
while (list(, $part) = each($multi)) {
$short_message = $part;
$sm_length = strlen($short_message);
$status = $this->SendSubmitMulti($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_arr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message);
if ($status != 0) {
$this->debug("SMPP server returned error $status.\n");
$result = false;
}
}
return $result;
}
// private members (not documented):
function ExpectPDU($our_sequence_number)
{
do {
$this->debug("Trying to read PDU.\n");
if (feof($this->_socket)) {
$this->debug("Socket was closed.!!\n");
}
$elength = fread($this->_socket, 4);
if (empty($elength)) {
$this->debug("Connection lost.\n");
return;
}
extract(unpack("Nlength", $elength));
$this->debug("Reading PDU : $length bytes.\n");
$stream = fread($this->_socket, $length - 4);
$this->debug("Stream len : " . strlen($stream) . "\n");
extract(unpack("Ncommand_id/Ncommand_status/Nsequence_number", $stream));
$command_id &= 0x0fffffff;
$this->debug("Command id : $command_id.\n");
$this->debug("Command status : $command_status.\n");
$this->debug("sequence_number : $sequence_number.\n");
$pdu = substr($stream, 12);
switch ($command_id) {
case CM_BIND_TRANSMITTER:
$this->debug("Got CM_BIND_TRANSMITTER_RESP.\n");
$spec = "asystem_id";
extract($this->unpack2($spec, $pdu));
$this->debug("system id : $system_id.\n");
break;
case CM_UNBIND:
$this->debug("Got CM_UNBIND_RESP.\n");
break;
case CM_SUBMIT_SM:
$this->debug("Got CM_SUBMIT_SM_RESP.\n");
if ($command_status == 0) {
$spec = "amessage_id";
extract($this->unpack2($spec, $pdu));
$this->debug("message id : $message_id.\n");
}
break;
case CM_SUBMIT_MULTI:
$this->debug("Got CM_SUBMIT_MULTI_RESP.\n");
$spec = "amessage_id/cno_unsuccess/";
extract($this->unpack2($spec, $pdu));
$this->debug("message id : $message_id.\n");
$this->debug("no_unsuccess : $no_unsuccess.\n");
break;
case CM_ENQUIRELINK:
$this->debug("GOT CM_ENQUIRELINK_RESP.\n");
break;
default:
$this->debug("Got unknown SMPP pdu.\n");
break;
}
$this->debug("\nReceived PDU: ");
for ($i = 0; $i < strlen($stream); $i++) {
if (ord($stream[$i]) < 32) $this->debug("(" . ord($stream[$i]) . ")"); else $this->debug($stream[$i]);
}
$this->debug("\n");
} while ($sequence_number != $our_sequence_number);
return $command_status;
}
function SendPDU($command_id, $pdu)
{
$length = strlen($pdu) + 16;
$header = pack("NNNN", $length, $command_id, $this->_command_status, $this->_sequence_number);
$this->debug("Sending PDU, len == $length\n");
$this->debug("Sending PDU, header-len == " . strlen($header) . "\n");
$this->debug("Sending PDU, command_id == " . $command_id . "\n");
fwrite($this->_socket, $header . $pdu, $length);
$status = $this->ExpectPDU($this->_sequence_number);
$this->_sequence_number = $this->_sequence_number + 1;
return $status;
}
function SendBindTransmitter($system_id, $smpppassword, $system_type)
{
$system_id = $system_id . chr(0);
$system_id_len = strlen($system_id);
$smpppassword = $smpppassword . chr(0);
$smpppassword_len = strlen($smpppassword);
$system_type = $system_type . chr(0);
$system_type_len = strlen($system_type);
$pdu = pack("a{$system_id_len}a{$smpppassword_len}a{$system_type_len}CCCa1", $system_id, $smpppassword, $system_type, 0x33, 0, 0, chr(0));
$this->debug("Bind Transmitter PDU: ");
for ($i = 0; $i < strlen($pdu); $i++) {
$this->debug(ord($pdu[$i]) . " ");
}
$this->debug("\n");
$status = $this->SendPDU(CM_BIND_TRANSMITTER, $pdu);
return $status;
}
function SendUnbind()
{
$pdu = "";
$status = $this->SendPDU(CM_UNBIND, $pdu);
return $status;
}
function SendSubmitSM($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_addr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message)
{
$service_type = $service_type . chr(0);
$service_type_len = strlen($service_type);
$source_addr = $source_addr . chr(0);
$source_addr_len = strlen($source_addr);
$destination_addr = $destination_addr . chr(0);
$destination_addr_len = strlen($destination_addr);
$schedule_delivery_time = $schedule_delivery_time . chr(0);
$schedule_delivery_time_len = strlen($schedule_delivery_time);
$validity_period = $validity_period . chr(0);
$validity_period_len = strlen($validity_period);
// $short_message = $short_message . chr(0);
$message_len = $sm_length;
$spec = "a{$service_type_len}cca{$source_addr_len}cca{$destination_addr_len}ccca{$schedule_delivery_time_len}a{$validity_period_len}ccccca{$message_len}";
$this->debug("PDU spec: $spec.\n");
$pdu = pack($spec,
$service_type,
$source_addr_ton,
$source_addr_npi,
$source_addr,
$dest_addr_ton,
$dest_addr_npi,
$destination_addr,
$esm_class,
$protocol_id,
$priority_flag,
$schedule_delivery_time,
$validity_period,
$registered_delivery_flag,
$replace_if_present_flag,
$data_coding,
$sm_default_msg_id,
$sm_length,
$short_message);
$status = $this->SendPDU(CM_SUBMIT_SM, $pdu);
return $status;
}
function SendSubmitMulti($service_type, $source_addr_ton, $source_addr_npi, $source_addr, $dest_addr_ton, $dest_addr_npi, $destination_arr, $esm_class, $protocol_id, $priority_flag, $schedule_delivery_time, $validity_period, $registered_delivery_flag, $replace_if_present_flag, $data_coding, $sm_default_msg_id, $sm_length, $short_message)
{
$service_type = $service_type . chr(0);
$service_type_len = strlen($service_type);
$source_addr = $source_addr . chr(0);
$source_addr_len = strlen($source_addr);
$number_destinations = count($destination_arr);
$dest_flag = 1;
$spec = "a{$service_type_len}cca{$source_addr_len}c";
$pdu = pack($spec,
$service_type,
$source_addr_ton,
$source_addr_npi,
$source_addr,
$number_destinations
);
$dest_flag = 1;
reset($destination_arr);
while (list(, $destination_addr) = each($destination_arr)) {
$destination_addr .= chr(0);
$dest_len = strlen($destination_addr);
$spec = "ccca{$dest_len}";
$pdu .= pack($spec, $dest_flag, $dest_addr_ton, $dest_addr_npi, $destination_addr);
}
$schedule_delivery_time = $schedule_delivery_time . chr(0);
$schedule_delivery_time_len = strlen($schedule_delivery_time);
$validity_period = $validity_period . chr(0);
$validity_period_len = strlen($validity_period);
$message_len = $sm_length;
$spec = "ccca{$schedule_delivery_time_len}a{$validity_period_len}ccccca{$message_len}";
$pdu .= pack($spec,
$esm_class,
$protocol_id,
$priority_flag,
$schedule_delivery_time,
$validity_period,
$registered_delivery_flag,
$replace_if_present_flag,
$data_coding,
$sm_default_msg_id,
$sm_length,
$short_message);
$this->debug("\nMulti PDU: ");
for ($i = 0; $i < strlen($pdu); $i++) {
if (ord($pdu[$i]) < 32) $this->debug("."); else $this->debug($pdu[$i]);
}
$this->debug("\n");
$status = $this->SendPDU(CM_SUBMIT_MULTI, $pdu);
return $status;
}
function split_message($text)
{
$this->debug("In split_message.\n");
$max_len = 153;
$res = array();
if (strlen($text) <= 160) {
$this->debug("One message: " . strlen($text) . "\n");
$res[] = $text;
return $res;
}
$pos = 0;
$msg_sequence = $this->_message_sequence++;
$num_messages = ceil(strlen($text) / $max_len);
$part_no = 1;
while ($pos < strlen($text)) {
$ttext = substr($text, $pos, $max_len);
$pos += strlen($ttext);
$udh = pack("cccccc", 5, 0, 3, $msg_sequence, $num_messages, $part_no);
$part_no++;
$res[] = $udh . $ttext;
$this->debug("Split: UDH = ");
for ($i = 0; $i < strlen($udh); $i++) {
$this->debug(ord($udh[$i]) . " ");
}
$this->debug("\n");
$this->debug("Split: $ttext.\n");
}
return $res;
}
function split_message_unicode($text)
{
$this->debug("In split_message.\n");
$max_len = 134;
$res = array();
if (mb_strlen($text) <= 140) {
$this->debug("One message: " . mb_strlen($text) . "\n");
$res[] = $text;
return $res;
}
$pos = 0;
$msg_sequence = $this->_message_sequence++;
$num_messages = ceil(mb_strlen($text) / $max_len);
$part_no = 1;
while ($pos < mb_strlen($text)) {
$ttext = mb_substr($text, $pos, $max_len);
$pos += mb_strlen($ttext);
$udh = pack("cccccc", 5, 0, 3, $msg_sequence, $num_messages, $part_no);
$part_no++;
$res[] = $udh . $ttext;
$this->debug("Split: UDH = ");
for ($i = 0; $i < strlen($udh); $i++) {
$this->debug(ord($udh[$i]) . " ");
}
$this->debug("\n");
$this->debug("Split: $ttext.\n");
}
return $res;
}
function unpack2($spec, $data)
{
$res = array();
$specs = explode("/", $spec);
$pos = 0;
reset($specs);
while (list(, $sp) = each($specs)) {
$subject = substr($data, $pos);
$type = substr($sp, 0, 1);
$var = substr($sp, 1);
switch ($type) {
case "N":
$temp = unpack("Ntemp2", $subject);
$res[$var] = $temp["temp2"];
$pos += 4;
break;
case "c":
$temp = unpack("ctemp2", $subject);
$res[$var] = $temp["temp2"];
$pos += 1;
break;
case "a":
$pos2 = strpos($subject, chr(0)) + 1;
$temp = unpack("a{$pos2}temp2", $subject);
$res[$var] = $temp["temp2"];
$pos += $pos2;
break;
}
}
return $res;
}
function debug($str)
{
if ($this->_debug) {
echo $str;
}
}
};
45 Comments

45 Responses to “Smpp library in php”

  1. mosaddek July 23, 2007 at 3:26 pm #

    I am getting error for smpp sms sending . Can u please provide me a solution??

    Parse error: parse error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\newsms\smppclass.php on line 19

  2. Valintino July 27, 2007 at 11:14 pm #

    Hello, Your site is great. Regards, Valintino Guxxi

  3. Chimere Okoro July 29, 2007 at 1:47 am #

    I like this approach but lately i’ve had to move an application to the Kannel WAP and SMS server. There seems to be little talk about benchmarks on the different PHP approaches to sending SMS.
    Am a lazy programmer, do u know of any comprehensive comparison between a daemonised smpp application and a server based approach like Kannel?

  4. ammar July 30, 2007 at 9:03 pm #

    Hello,
    this class is good but there is a problem when i tried to send more than one part SM, it goes wrong and it returned me the error 8.
    do you know how to over come this problem.
    Ammar N

  5. andz August 14, 2007 at 3:23 pm #

    I think it`s kinda unfinished

  6. Dean October 18, 2007 at 3:09 am #

    Can you also create function to get message_id from message that was sent

  7. Sajith M.R October 18, 2007 at 9:05 am #

    Hello Dean ,

    The smpp library given has limited functionalities. Dont have support for dlr and no transiever and hence no need of message id in the library. The ultimate solution is kannel server with sql box.

  8. Mohamad Ali November 8, 2007 at 11:35 am #

    SMPP server returned error 1

  9. oscar April 16, 2008 at 10:08 pm #

    Hi, what happen if i want to send a SMS with characters like… ‘Ñ’ or ‘_’ ‘%’ etc…? i have read that i should encode it to 7-bit but it doesn’t work, anybody can give a solution?

    thanks

  10. Trihan June 3, 2008 at 3:43 pm #

    uhm.. finally i can send multiple messages (> 160 char).
    Thanks for the complete smppclass.php.

    Yesterday i got smppclass but it can only send message (max 160 char). when i send message more than 160 char, it sends only first 160 char.
    when i change with your smppclss, it works…

    Thx.

  11. niamanesh July 10, 2008 at 10:55 am #

    hi
    I Have a problem . my script unbind auto befor send sms and i recive error:SMPP server returned error 195

  12. Loyc July 12, 2008 at 1:31 am #

    How can i get a smpp account?

  13. adnan September 9, 2008 at 6:25 am #

    thank’s be 4.
    How I can get report of after I’m send my sms, Thank’s a lot.

  14. Prashanth November 27, 2008 at 4:18 pm #

    hi i am getting this Error Number when i try to use this

    SMPP server returned error 3.

  15. leo baringin January 13, 2009 at 2:05 pm #

    Good script for broadcasting sms…

  16. narayan January 22, 2009 at 7:58 pm #

    Hi,

    While using the class, I am able to send sms with the sender id … it gets delivered and all but the message is not received only the sender id is received. … no text at all

    checked out the code … till pack pdu also the message is intact … but after that I do not know what happens while sending…

    any clues …

    thanks

  17. narayanan January 22, 2009 at 10:14 pm #

    hi

    used this class .. found i could send sms with sender id … but the text of the sms doesnot get sent to the customer .. not able to understand why..

    uptil pack the message is test … but am not sure at pack what is happeni ng .. no text in the sms (received alao)

  18. alma May 22, 2009 at 5:55 pm #

    haw can do with interface this class?

  19. ami May 22, 2009 at 5:57 pm #

    can you tell me the way that i can send SMS .

  20. Sandesh Magdum July 7, 2009 at 6:48 pm #

    The SendMulti function is not working!

    I am currently using Send function in a for loop for multiple messages.

    Hope someone solve my problem.

    Thanks in advance!

    Regards

    Sandesh.

  21. Ndank July 28, 2009 at 2:10 pm #

    Send multi not works….
    I try using send multi, there is a problem :
    Fatal error: pack type a: not enough input, need 1, have 0 ….

  22. makki July 29, 2009 at 10:08 am #

    hi.

    it is absolutely fine, but how can i get the Message Id from SMSC ?

  23. makki August 3, 2009 at 10:33 am #

    SendMulti is really needed. M still confused how to do it. any body will help me for this?

  24. Atul November 10, 2009 at 8:08 pm #

    i am using ruby smpp-0.1.2 for sending and receiving sms for smsc but ruby smpp use to get stopped after sometime by itself. Can you plz solve this problem

  25. Rakesh November 13, 2009 at 5:36 pm #

    Hi,
    Your code is simply nice. But it’s not working to send multiple messages. I want to send bulk sms. Please help me out.

  26. manibalan November 20, 2009 at 4:50 pm #

    its works fine for me and pls any one help how i will receive or retrieve the message in the server

  27. Unni Krishnan January 13, 2010 at 5:57 pm #

    Hi Sandesh Magdum,for point of time solution, dont use send function in a loop…since if you think of the app in future that needs to send bulk sms > 50 k sms at one go..will be a problem..so better make sendmulti function work and use it..that cud be better, me too having same issue..so im working on it, if it seems to work ill post the solution here..also there is Pear library for smpp..can download it here http://pear.php.net/package/Net_SMPP/download..am trying that too

  28. Manjula January 15, 2010 at 10:00 am #

    Thanks for help. But i have a problum with sending phone no and reciver no.
    I am SriLankan user.

    $from = “919846341106″; // From number
    $smpp->Send(“971532663061″, “XXXXX”);

    let me know the sample number for SriLanka like $to = “94757555441″;

    is this correct for sri lanka

  29. mina February 10, 2010 at 12:22 pm #

    tthanks u so much for ur usefull content, but could u please send me an interface for smpp client?

  30. kiran March 15, 2010 at 2:51 pm #

    Hi,

    I have seen some PHP Implementation of SMPP client (ESME) . In commercial, they fails since the SMPP implementation does not support all PDU’s. Ex : submit_multi does not support in almost all SMPP connections. For sending bulk sms only way is to loop through the Sending List. In commercial applications, if we have the smpp account, the connection will be transient in the sense that, the connection will be live for 24 hours. Only then the provider pushes DLR to our application. So actual implementation of SMPP Client requires a lot of methods for handling connection . Threading is a necessary thing for SMPP applications. So before proceeding with PHP, think about its feasibility !!!!
    Thanks

  31. gyan April 22, 2010 at 2:25 pm #

    i am PHP developer from india

    i am trying to send sms from your given code.

    it is send sms from my local system but wgen is am sending this code from online server it give the error:

    =============================
    Warning: fsockopen() [function.fsockopen]: unable to connect to 64.56.75.242:5555 (Connection timed out) in /home/content/v/a/p/vapsoft/html/smppclass.php on line 82
    Error opening SMPP session. Error was: Connection timed out. Sending PDU, len == 16 Sending PDU, header-len == 16 Sending PDU, command_id == 21
    Warning: fwrite(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 355
    Trying to read PDU.
    Warning: feof(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 289

    Warning: fread(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 292
    Connection lost. Not connected, while trying to send SUBMIT_SM. In split_message. One message: 68 PDU spec: a1cca8cca13ccca1a1ccccca68. Sending PDU, len == 120 Sending PDU, header-len == 16 Sending PDU, command_id == 4
    Warning: fwrite(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 355
    Trying to read PDU.
    Warning: feof(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 289

    Warning: fread(): supplied argument is not a valid stream resource in /home/content/v/a/p/vapsoft/html/smppclass.php on line 292
    Connection lost.

    ===============================
    please help me.

  32. snow June 15, 2010 at 2:57 pm #

    hi all i have the same problem in sending bulk sms
    what can we do ? any one solve this problem
    ??
    note : it work will to send for only one number??
    I am try and Waiting>>>

  33. adrian August 7, 2010 at 5:29 pm #

    The code works fine without modification, even with send_multi.

    I wonder could the problems the others are facing be operator dependent?

  34. anandh January 13, 2011 at 1:53 pm #

    Hai Sajith,
    Hats off to you. Your SMPP bind program works fine.

    My hearty congratulationn to you.

    Regards,
    S. Anandh

  35. anandh January 19, 2011 at 7:18 pm #

    Hai Sajith,
    Your SMPP Bind request works fine. But If I use Multisend function message content is not delivered only empty message delivered to the recipients. please provide solution.
    Regards,
    Anandh,Coimbatore

  36. ilkera March 16, 2011 at 8:50 am #

    I need your help. This is my Error.

    PHP Warning: fsockopen(): unable to connect to 192.168.0.11:5018 (Connection refused) in xxxxxxxx/smppclass.php on line 87
    Error opening SMPP session.
    Error was: Connection refused.
    Sending PDU, len == 16
    Sending PDU, header-len == 16
    Sending PDU, command_id == 21
    PHP Warning: fwrite(): supplied argument is not a valid stream resource in /xxxxxxxxxxx/smppclass2.php on line 359
    Trying to read PDU.
    PHP Warning: feof(): supplied argument is not a valid stream resource in /xxxxxxxxxxxx/smppclass2.php on line 293
    PHP Warning: fread(): supplied argument is not a valid stream resource in /xxxxxxxxxxxx/smppclass2.php on line 296
    Connection lost.
    Not connected, while trying to send SUBMIT_SM.
    In split_message.
    One message: 69
    PDU spec: a1cca13cca13ccca1a1ccccca69.
    Sending PDU, len == 126
    Sending PDU, header-len == 16
    Sending PDU, command_id == 4
    PHP Warning: fwrite(): supplied argument is not a valid stream resource in /xxxxxxxxxx/smppclass.php on line 359
    Trying to read PDU.
    PHP Warning: feof(): supplied argument is not a valid stream resource in /xxxxxxxxx/smppclass.php on line 293
    PHP Warning: fread(): supplied argument is not a valid stream resource in /xxxxxxxxxx/smppclass.php on line 296
    Connection lost.

    How can i resolved this. thank for your help
    I have 2 files :
    -transmit.php
    -smppclass.php

  37. sashi May 2, 2011 at 3:35 pm #

    I am getting below error:

    Warning: unpack() [function.unpack]: Type a: not enough input, need 1, have 0 in C:\xampp\htdocs\pushsms\smppclass.php on line 596

    Please help. Basically i need to develop a bulk sms sender.

  38. sashi May 2, 2011 at 3:37 pm #

    Another error i get is:

    system id : . Received PDU: €(0)(0)(0)(0)(0)(0)(3)(0)(0)(0)(1) Error binding to SMPP server. Invalid credentials? Sending PDU, len == 34 Sending PDU, header-len == 16 Sending PDU, command_id == CM_ENQUIRELINK Trying to read PDU. Reading PDU : 16 bytes. Stream len : 12 Command id : 0. Command status : 3. sequence_number : 2. Got CM_BIND_TRANSMITTER_RESP.

    What is system_type? What is the difference between system_type and systemID here? Please help.

  39. Sici July 14, 2011 at 3:40 am #

    Hello, I implemented this class, but when you run it I get these errors

    Bind Transmitter PDU: 109 111 109 97 114 101 115 0 109 111 109 97 114 101 115 54 55 56 56 0 51 51 49 56 56 55 54 0 51 0 0 0 Sending PDU, len == 48 Sending PDU, header-len == 16 Sending PDU, command_id == 2 Trying to read PDU. Reading PDU : 17 bytes. Stream len : 13 Command id : 2. Command status : 13. sequence_number : 1. Got CM_BIND_TRANSMITTER_RESP. system id : . Received PDU: €(0)(0)(2)(0)(0)(0)(13)(0)(0)(0)(1)(0) Error binding to SMPP server. Invalid credentials? Sending PDU, len == 16 Sending PDU, header-len == 16 Sending PDU, command_id == 21 Trying to read PDU. Connection lost. In split_message. One message: 24 PDU spec: a1cca6cca13ccca1a1ccccca24. Sending PDU, len == 74 Sending PDU, header-len == 16 Sending PDU, command_id == 4 Trying to read PDU. Socket was closed.!! Connection lost. Sending PDU, len == 16 Sending PDU, header-len == 16 Sending PDU, command_id == 6 Trying to read PDU. Socket was closed.!! Connection lost.

    The parameters are ok, but they can be?

  40. P JOTHIRAJAN August 5, 2011 at 11:28 am #

    Sir,
    I am getting the following message.
    can you give me your suggestion

    ——————-
    Bind Transmitter PDU: 83 90 66 73 76 76 84 82 0 115 122 98 105 108 108 116 114 0 83 90 66 73 76 76 84 82 0 51 0 0 0
    PHP Notice: Use of undefined constant CM_BIND_TRANSMITTER – assumed ‘CM_BIND_TRANSMITTER’ in /root/Downloads/smppexample.php on line 431
    Sending PDU, len == 47
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_BIND_TRANSMITTER
    Trying to read PDU.
    Reading PDU : 16 bytes.
    Stream len : 12
    Command id : 0.
    Command status : 3.
    sequence_number : 0.
    PHP Notice: Use of undefined constant CM_BIND_TRANSMITTER – assumed ‘CM_BIND_TRANSMITTER’ in /root/Downloads/smppexample.php on line 364
    Got CM_BIND_TRANSMITTER_RESP.
    PHP Warning: unpack(): Type a: not enough input, need 1, have 0 in /root/Downloads/smppexample.php on line 620
    system id : .

    Received PDU: �(0)(0)(0)(0)(0)(0)(3)(0)(0)(0)(0)
    Trying to read PDU.
    Connection lost.
    PHP Notice: Use of undefined constant CM_ENQUIRELINK – assumed ‘CM_ENQUIRELINK’ in /root/Downloads/smppexample.php on line 263
    Sending PDU, len == 16
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_ENQUIRELINK
    PHP Notice: fwrite(): send of 16 bytes failed with errno=32 Broken pipe in /root/Downloads/smppexample.php on line 411
    Trying to read PDU.
    Socket was closed.!!
    Connection lost.
    In split_message.
    One message: 22
    PDU spec: a4cca12cca10ccca1a1ccccca22.
    PHP Notice: Use of undefined constant CM_SUBMIT_SM – assumed ‘CM_SUBMIT_SM’ in /root/Downloads/smppexample.php on line 478
    Sending PDU, len == 78
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_SUBMIT_SM
    PHP Notice: fwrite(): send of 78 bytes failed with errno=32 Broken pipe in /root/Downloads/smppexample.php on line 411
    Trying to read PDU.
    Socket was closed.!!
    Connection lost.
    PHP Fatal error: Call to undefined function mb_convert_encoding() in /root/Downloads/smppexample.php on line 204

    —————-

    with regards,
    jothirajan

  41. P JOTHIRAJAN August 8, 2011 at 6:51 pm #

    Sir,
    I am getting the following message.
    can you give me your suggestion

    ——————-
    Bind Transmitter PDU: 83 90 66 73 76 76 84 82 0 115 122 98 105 108 108 116 114 0 83 90 66 73 76 76 84 82 0 51 0 0 0
    PHP Notice: Use of undefined constant CM_BIND_TRANSMITTER – assumed ‘CM_BIND_TRANSMITTER’ in /root/Downloads/smppexample.php on line 431
    Sending PDU, len == 47
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_BIND_TRANSMITTER
    Trying to read PDU.
    Reading PDU : 16 bytes.
    Stream len : 12
    Command id : 0.
    Command status : 3.
    sequence_number : 0.
    PHP Notice: Use of undefined constant CM_BIND_TRANSMITTER – assumed ‘CM_BIND_TRANSMITTER’ in /root/Downloads/smppexample.php on line 364
    Got CM_BIND_TRANSMITTER_RESP.
    PHP Warning: unpack(): Type a: not enough input, need 1, have 0 in /root/Downloads/smppexample.php on line 620
    system id : .

    Received PDU: �(0)(0)(0)(0)(0)(0)(3)(0)(0)(0)(0)
    Trying to read PDU.
    Connection lost.
    PHP Notice: Use of undefined constant CM_ENQUIRELINK – assumed ‘CM_ENQUIRELINK’ in /root/Downloads/smppexample.php on line 263
    Sending PDU, len == 16
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_ENQUIRELINK
    PHP Notice: fwrite(): send of 16 bytes failed with errno=32 Broken pipe in /root/Downloads/smppexample.php on line 411
    Trying to read PDU.
    Socket was closed.!!
    Connection lost.
    In split_message.
    One message: 22
    PDU spec: a4cca12cca10ccca1a1ccccca22.
    PHP Notice: Use of undefined constant CM_SUBMIT_SM – assumed ‘CM_SUBMIT_SM’ in /root/Downloads/smppexample.php on line 478
    Sending PDU, len == 78
    Sending PDU, header-len == 16
    Sending PDU, command_id == CM_SUBMIT_SM
    PHP Notice: fwrite(): send of 78 bytes failed with errno=32 Broken pipe in /root/Downloads/smppexample.php on line 411
    Trying to read PDU.
    Socket was closed.!!
    Connection lost.
    PHP Fatal error: Call to undefined function mb_convert_encoding() in /root/Downloads/smppexample.php on line 204

    —————-

    with regards,
    jothirajan

  42. Akshay Agarwal August 15, 2011 at 3:51 pm #

    For everybody getting a warning fsockopen() error, most probably you are running your script on a shared server & most of them have blocked sockets, so this script NOT work on shared servers. You may use curl as an alternative or fopen() if your SMSC supports that.

    To run this script you will need a VPS

    If anybody is looking for customized SMS applications, you can contact me for professional consultancy & development

    info[at]akshayagarwal.in

  43. Anandh February 15, 2012 at 12:14 pm #

    Dear Anybody,
    The coding works fine. I want to sent flash SMS/ Silent SMS.
    It would be most appreciated if anybody provide the corresponding settings for the above codes?

    Thanks in advance.

  44. Gopal Tripathi February 26, 2012 at 12:29 pm #

    Dear,

    I need a complete web based php application for sending bulk sms, in which i want to create users & resellers, add or deduct sms credits, with full delivery report of all sent sms. I want to use smpp connection for sending sms & receiving reports.

    If you can provide me, please contact me ASAP

Trackbacks/Pingbacks

  1. MrRudy - August 17, 2007

    Feedburner…

    I can’t add your feed to Feedburner. How I do this?…

Leave a Reply

More in php, php source code (101 of 111 articles)


Hello Friends, Memory management is the main problem when you extent your website over a wide range. In php ...