PHP Sending SMS via SMTP

From SMS Wiki
Revision as of 14:32, 11 May 2007 by Administrator (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Example code to send text messages written in php. This code requires phpmailer class. You can download free phpmailer from http://phpmailer.sourceforge.net/. This code is provided as sample only.

<?php
require("class.phpmailer.php");
 
$mail = new PHPMailer();
 
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.upsidewireless.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Port =25;
$mail->Username = "yourusername";
$mail->Password = "yourpassword";
 
$mail->From = "yourusername@smtp.upsidewireless.com";
$mail->FromName = "Your Name";
$mail->AddAddressTo("DestinationPhoneNumber@sms.upsidewireless.com", "Receiver Name");
 
$mail->Subject = ""; // insert compression options if desired
$mail->Body = "Your Message";
 
if($mail->Send())
{
  // Success
} else {
  // Failure
}
 
?>