title: Php Function to send SMS via Kannel
body: <p>I can now send an SMS via kannel. However this is done via headers eg:</p>
  
  <pre><code>header("Location:http://localhost:13013/cgi-bin/sendsms?username=xxxx&amp;password=xxxx&amp;to=$in_number&amp;text=$in_msg");  
  </code></pre>
  
  <p>I want to send an sms via a php function and I got the code below online but it doesn't work. (Kannel smsbox log shows no request):</p>
  
  <pre><code>  function sendSmsMessage($in_number, $in_msg)
   {
   $url = '/cgi-bin/sendsms?username=' . CONFIG_KANNEL_USER_NAME
   . '&amp;password=' . CONFIG_KANNEL_PASSWORD    
   . '&amp;charset=UCS-2&amp;coding=2'
   . "&amp;to={$in_number}"
   . '&amp;text=' . urlencode(iconv('utf-8', 'ucs-2', $in_msg));
  
  
  
  $results = file('http://'  
                   . CONFIG_KANNEL_HOST . ':'
                   . CONFIG_KANNEL_PORT . $url);
  </code></pre>
  
  <p>}</p>
  
  <p>Is there something wrong? I tried replacing the CONFIG_KANNEL_USER_NAME and the rest with the actual values but it still doesn't work. Open to suggestions.</p>