PHP Sending SMS via SMTP

From SMS Wiki
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/

<?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
}
 
?>