SMS Server Tools 3: Send a Blank SMS using a PHP Script CodeUnit 25 JAN 2010

SMS Server Tools 3 is a great little SMS Gateway software which you can pair up nicely with some PHP scripts in order to send and receive SMSes.

Today’s little trick shows you how to send a blank (i.e. no text body) SMS using a PHP script to generate the outgoing spool file.

//$body is SMS text body | $phone is number being sent to
$handle = fopen('/var/spool/sms/outgoing/filesendname, "w");
$body = stripslashes(urldecode($body));
fputs($handle, "To: +$phonen");
fputs($handle, "Alphabet: ISO8859-15n");
fputs($handle, "n");
if (strlen($body) > 0)
{
    fputs($handle, "$body");
}
else
{
    fputs($handle, "n");
}
fclose($handle);

What the script does is actually pretty simple at heart. The first step is to create a new file handle in which to store the SMS contents, this file being created in the outgoing spool folder specified by your SMS3 configuration. Then you simply insert the correct text into the file, ensuring you keep strictly to the format used in the example above. The only little trick is that in order for it to process correctly when it comes to blank SMSes, you need to insert a new line n character to replace what would have been the SMS body.

And Bob’s your uncle.

Related Link: http://smstools3.kekekasvi.com/

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.

  • “No candle loses its light while lighting another candle” So never stop sharing and helping others because it makes ur life more meaningful.

  • “No candle loses its light while lighting another candle” So never stop sharing and helping others because it makes ur life more meaningful.

  • I suggest http://www.adforte.com, free api, cheap sms, worldwide.

  • I suggest http://www.adforte.com, free api, cheap sms, worldwide.