Difference between revisions of "PHP Sending SMS via SMTP"

From SMS Wiki
Jump to: navigation, search
(New page: 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 samp...)
 
 
Line 1: Line 1:
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.
+
Example code to send text messages written in php. This code requires phpmailer class. You can download free phpmailer from http://phpmailer.sourceforge.net/
  
 
<source lang="php">
 
<source lang="php">

Latest revision as of 15:35, 11 May 2007

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