Receiving SMS from Third Party Gateways
This chapter describes receiving SMS coming from third party gateways as emails.
IceWarp Server user sends a SMS message via HTTP, this message is delivered by third party SMS gateway, the recipient answers from their cell phone, this answer is posted to IceWarp Server (script in the <install_dir>/html/sms directory see further) and delivered to the user as an email message.
Note: The deliver.html file is a raw example of such a script. There are more examples of scripts for other providers within this directory.
It is necessary to have an incoming number (called "MO") from your provider. Furthermore, you have to define a gateway (within SMS General) and put both ID and password = 1 (as defined in the appropriate script HTML file in the <install_dir>/html/sms directory as internal security).
Example of such an HTML file receive_routomessaging_uk.html:
<?php
// PHP script called by Routomessaging (http://www.routomessaging.com/) via HTTP POST to deliver SMSs to IceWarp as e-mails.
// A special thanks to Marko Dukanac from Routomessaging
// Notice in this case that the gateway ID and password of the gateway in IceWarp both have a value of "1".
// More details in F1 help (HTTP Request Delivery Script section)
// variables accepted by routo
//
// user
// pass
// org (body of message)
// dest (recipient number)
// dcs (default enconding)
// message (body of message)
// Shared libraries
define(SHAREDLIB_PATH, get_cfg_var('icewarp_sharedlib_path'));
include(SHAREDLIB_PATH . 'api/api.php');
// Build $url with gateway's parameters to pass to IceWarp API
// id=1 ==> id of Clickatell gateway in Icewarp SMS/General admin
// pass=1 ==> password defined in Icewarp SMS/General admin
$url =
'number=' . urlencode($_REQUEST['org']) .
'&id=1' .
'&pass=1' .
'&data=' . urlencode($_REQUEST['message']);
// Deliver SMS to IceWarp
$api = new IceWarpAPI();
$result = $api->SMSIncoming($url);
// Result
if (!$result) { header('HTTP/1.1 503 Service Unavailable'); }
?>
At the HTTP gateway, you have to enable an option that does an HTTP POST to, for example, http://mail.yourdomain.com/sms/receive_routomessaging_uk.html.
Logging
Every message is registered in IceWarp API log, which has to be enabled. If processing is OK, it returns True in a log, otherwise it returns False.
Example:
SYSTEM [1740] 12:10:27 <<< NIL->Create(icewarpserver.apiobject)
SYSTEM [1740] 12:10:27 >>> (0 ms) NIL->Create(158606136)
SYSTEM [1740] 12:10:27 <<< TAPIObject(158606136)->SMSIncoming(number=5511999999999&id=1&pass=1&data=SMS+for+%23emailaccount%40mydomain.com%23.,,,,)
SYSTEM [1740] 12:10:27 >>> (0 ms) TAPIObject(158606136)->SMSIncoming(True)