Sendsms.php doesn't work with nowsms cloud?

Sendsms.php doesn't work with nowsms cloud? SearchSearch
Author Message
New member
Username: Nigel

Post Number: 1
Registered: 07-2017
Posted on Sunday, July 09, 2017 - 07:33 pm:   


i have used nowsms gateway before with sendsms.php, but i cannot figure out how to use it with cloud version.

i think maybe it is port number? cloud version only supports https://, does not support http://

i tried port number 443, but cannot make it work.


Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 8170
Registered: 10-2002
Posted on Sunday, July 09, 2017 - 08:37 pm:   

Hi nigel,

We have a few web pages that we still need to update.

Basically, the old sendsms.php used raw plain text socket i/o, and does not understand SSL/TLS encryption as required for https:// requests.

sendsms.php is a rather simple we changed the way it issues HTTP requests so that it will work for http:// or https://

This does require a minor parameter change...the first two parameters for the old version were host name or IP, followed by the port number. In the new version, instead these are combined into a single parameter, which is the URL of the NowSMS server (e.g., or


function SendSMS ($hostUrl, $username, $password, $phoneNoRecip, $msgText) {

// Parameters:
// $hostUrl – URL of the NowSMS server (e.g., or
// $username – “SMS Users” account on the NowSMS server
// $password – Password defined for the “SMS Users” account on the NowSMS Server
// $phoneNoRecip – One or more phone numbers (comma delimited) to receive the text message
// $msgText – Text of the message

$postfields = array('Phone'=>"$phoneNoRecip", 'Text'=>"$msgText");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hostUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
// curl_setopt($ch, CURLOPT_VERBOSE, true);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
// curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // change to 1 to verify cert
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($ch);

return $result;


// This code provides an example of how you would call the SendSMS function from within
// a PHP script to send a message. The response from the NowSMS server is echoed back from the script.

$x = SendSMS('', 'username', 'password', '+44999999999', 'Test Message');
echo $x;


sendsms.php.txt (1.6 k)


Bryce Norwood
Now SMS/MMS Support

P.S. - I should mention there are a few lines commented out. In this version, the SSL certificate is not checked for validity. We still need to do testing to determine the best way to do this in PHP.
New member
Username: Nigel

Post Number: 2
Registered: 07-2017
Posted on Monday, July 10, 2017 - 02:22 pm:   


Add Your Message Here, or click here to start a new topic.
Bold text Italics Underline Create a hyperlink Insert a clipart image
Options: Automatically activate URLs in message