I've copied this from an answer I gave in relation to this question. However, in addition to the text below, take a look at Wadja's SMS Gateway deals (API link)... they appear to be a really good option at the moment, though I've not used them, personally.
Your main option for sending SMS messages is using an existing SMS provider. In my experience (which is extensive with SMS messaging web applications), you will often find that negotiating with different providers is the best way to get the best deal for your application.
Different providers often offer different services, and different features. My favourite provider, and indeed, the one that has happily negotiated with me for lower rates in the past, is TM4B (http://www.tm4b.com). These guys have excellent rates, cover a huge proportion of the globe, and have excellent customer service.
Below is some code extracted (and some parts obfuscated) from one of my live web applications, for sending a simple message via their API:
require_once("tm4b.lib.php");
$smsEngine = new tm4b();
// Prepare the array for sending
$smsRequest["username"] = "YOURUNAME";
$smsRequest["password"] = "YOURPWORD";
$smsRequest["to"] = "+441234554443";
$smsRequest["from"] = "ME!";
$smsRequest["msg"] = "Hello, test message!";
// Do the actual sending
$smsResult = $smsEngine->ClientAPI($smsRequest);
// Check the result
if( $smsResult['status'] == "ok" ) {
print "Message sent!";
} else {
print "Message not sent.";
}
Many other providers that I've used in the past, have very similar interfaces, and all are really competitive when it comes to pricing. You simply have to look around for a provider that suits your needs.
In regard to cost, you're looking at prices ranging from a few pence/cents for most Western countries (prices are a little bit higher for most third-world countries, though, so beware). Most providers you will have to pay in bulk, if you want decent rates from them, but they'll often negotiate with you for 'smaller-than-usual' batches. Most providers do offer a post-pay option, but only when you've successfully completed a few transactions with them... others offer it from the start, but the prices are extortionate.
Hope it helps!