November18
You can send SMS (TXT Messages) for free to most Phone carriers by sending an email to their Email to SMS gateway.
A list of carriers email to SMS gateways is here:
http://en.wikipedia.org/wiki/List_of_SMS_gateways
I wrote a class based on this a while ago but never got around to finishing it:
< ?php
/**
* Send SMS via Email to SMS gateways
*
* Please note that the list of carreirs is UTF-8 encoded. ie: Mexico != México
*
* @author gabe@fijiwebdesign.com
* @link http://www.fijiwebdesign.com/
*/
class email2sms {
/**
* A list of the major Phone carriers and their Email 2 SMS gateway syntax
* Compiled from: http://en.wikipedia.org/wiki/List_of_carriers_providing_SMS_transit
*/
protected static $carriers = array(
array("Airtel", "Andhra Pradesh, India", "#@airtelap.com"),
array("Airtel", "Karnataka, India", "#@airtelkkk.com"),
array("Alaska Communications Systems", "USA", "#@msg.acsalaska.net"),
array("Alltel Wireless Verizon Wireless", "USA", "#@text.wireless.alltel.com,#@mms.alltel.net"),
array("aql", "UK", "#@text.aql.com"),
array("AT&T Wireless", "USA", "#@txt.att.net,#@mms.att.net"),
array("AT&T", "USA", "#@mmode.com"),
array("AT&T Mobility", "USA", "#@mms.att.net,#@txt.att.net,#@cingularme.com"),
array("AT&T", "USA", "#@page.att.net"),
array("Bell", "Canada", "#@txt.bell.ca,#@txt.bellmobility.ca"),
array("Boost Mobile", "USA", "#@boostmobile.com"),
array("Bouygues Télécom (company)", "France", "#@mms.bouyguestelecom.fr"),
array("[[Loop_Mobile_India|Loop] (BPL Mobile)", "Mumbai, India", "#@bplmobile.com"),
array("Cellular One", "USA", "#@mobile.celloneusa.com"),
array("Cingular", "USA", "#@cingular.com"),
array("Centennial Wireless", "United States, Puerto Rico, U.S. Virgin Islands", "#@cwemail.com"),
array("Cincinnati Bell", "Cincinnati, Ohio, USA", "#@gocbw.com,#@mms.gocbw.com"),
array("Claro", "Brasil", "#@clarotorpedo.com.br"),
array("Claro", "Nicaragua", "#@ideasclaro-ca.com"),
array("Comcel", "Colombia", "#@comcel.com.co"),
array("Cricket", "", "#@mms.mycricket.com,#@sms.mycricket.com"),
array("CTI Móvil Claro", "Argentina", "#@sms.ctimovil.com.ar"),
array("Emtel", "Mauritius", "#@emtelworld.net"),
array("Fido", "Canada", "#@fido.ca"),
array("General Communications Inc.", "Alaska", "#@msg.gci.net"),
array("Globalstar satellite", "", "#@msg.globalstarusa.com"),
array("Helio", "", "#@myhelio.com"),
array("Iridium", "", "#@msg.iridium.com"),
array("i-wireless (Sprint PCS)", "", "#@iwirelesshometext.com"),
array("Mero Mobile", "Nepal", "#@sms.spicenepal.com"),
array("MetroPCS", "", "#@mymetropcs.com"),
array("Movicom", "", "#@movimensaje.com.ar"),
array("Mobitel", "Sri Lanka", "#@sms.mobitel.lk"),
array("Movistar", "Colombia", "#@movistar.com.co"),
array("MTN", "South Africa", "#@sms.co.za"),
array("MTS Mobility", "Canada", "#@text.mtsmobility.com"),
array("Nextel", "United States", "#@messaging.nextel.com"),
array("Nextel", "México", "#@msgnextel.com.mx"),
array("Nextel", "Argentina", "#@nextel.net.ar"),
array("Orange Polska", "Poland", "#@orange.pl"),
array("Personal", "Argentina", "#@alertas.personal.com.ar"),
array("Plus", "Poland", "#@text.plusgsm.pl"),
array("PC Telecom", "Canada", "#@mobiletxt.ca"),
array("Qwest Wireless", "USA", "#@qwestmp.com"),
array("Rogers Wireless", "Canada", "#@pcs.rogers.com"),
array("SaskTel", "Canada", "#@sms.sasktel.com"),
array("Setar", "Aruba", "#@mas.aw"),
array("Sprint (PCS)", "USA", "#@messaging.sprintpcs.com,#@pm.sprint.com"),
array("Sprint (Nextel)", "USA", "#@page.nextel.com,#@messaging.nextel.com"),
array("Suncom", "", "#@tms.suncom.com"),
array("Sunrise Communications", "Switzerland", "#@gsm.sunrise.ch"),
array("Syringa Wireless", "USA", "#@rinasms.com"),
array("T-Mobile", "USA", "#@tmomail.net"),
array("T-Mobile", "Austria", "#@sms.t-mobile.at"),
array("T-Mobile", "Croatia", "#@sms.t-mobile.hr"),
array("Telus Mobility", "Canada", "#@msg.telus.com"),
array("Tigo", "Colombia", "#@sms.tigo.com.co"),
array("Tracfone", "", "#@mmst5.tracfone.com,#@txt.att.net,#@tmomail.net,#@vtext.com,#@email.uscc.net,#@message.alltel.com"),
array("Unicel", "USA", "#@utext.com"),
array("US Cellular", "USA", "#@email.uscc.net,#@mms.uscc.net"),
array("Verizon", "USA", "#@vtext.com,#@vzwpix.com"),
array("Viaero", "USA", "#@viaerosms.com,#@mmsviaero.com"),
array("Vivo", "Brasil", "#@torpedoemail.com.br"),
array("Virgin Mobile", "Canada", "#@vmobile.ca"),
array("Virgin Mobile", "USA", "#@bills.com,#@vmobl.com,#@vmpix.com"),
array("Vodacom", "South Africa", "#@voda.co.za")
);
/**
* Send an SMS to a Phone Number
* @return Bool
* @param $msg String SMS/TXT message
* @param $to Int Receivers Phone number
* @param $from String From Email address or phone number
* @param $carrier String Carrier Name (index of self::$carriers)
*
* @todo at the moment we only send to the first listed email
* In the future it would be good to check the existence of mailbox at each domain
*
*
*/
public function send($msg, $to, $carrier, $from) {
$carriers = self::$carriers;
if (!isset($carriers[$carrier])) {
throw new Exception('The requested carrier was not found');
return false;
}
$addresses = explode(',', $carriers[$carrier][2]);
$address = str_replace('#', $to, $addresses[0]);
if (!mail($address, $msg, $msg, "from:$from\n")) {
throw new Exception('The Email could not be sent to SMS gateway');
return false;
}
return true;
}
/**
* Return a Carrier by phone number
* @return Array
* @param $name String
*/
public function getCarrierByNumber($number) {
// todo
// here we would query MTA at each domain for mailbox existence
}
/**
* Return a Carrier by name
* @return Array
* @param $name String
*/
public function getCarrierByName($name) {
return isset(self::$carriers[$name]) ? self::$carriers[$name] : null;
}
/**
* Retrieve a list of Carriers by region
* @return Array
* @param $region String[optional] Return only gateways in this region. eg: "USA" or "India"
*/
public function getCarriersByRegion($region = false) {
$carriers = self::$carriers;
if ($region) {
$_carriers = array();
$region = strtolower($region);
foreach($carriers as $carrier) {
if (in_array($region, explode(', ', strtolower($carrier[1])))) {
$_carriers[] = $carrier;
}
}
return $_carriers;
}
return $carriers;
}
/**
* Retrieve the regions in carrier list
* @return Array
*/
public function getRegions() {
$regions = array();
foreach(self::$carriers as $carrier) {
$regions[$carrier->region] = 1;
}
return array_keys($regions);
}
}
?>