Send SMS from PHP

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/. 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"; // username

$mail->Password = "YourPassword"; // password

$mail->From = "YourUserName@smtp.upsidewireless.com";

$mail->FromName = "Your Name";

$mail->AddAddressTo("DestinationPhoneNumber@sms.upsidewireless.com", "Receiver Name");


$mail->Subject = "Compression Option goes here - find out more";

$mail->Body = "Your Message";


if(!$mail->Send())

{

echo "Message could not be sent.

"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; ?>