Reputation: 5309
I am trying to send SMS using phpmailer with my gmail account.
This is my code:
require_once('../class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Username = "[email protected]";
$mail->Password = "mypassword";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SetFrom('[email protected]', 'DS');
$mail->Subject = 'hello';
$mail->Body = 'this is a testing mail..';
$mail->AddAddress('[email protected]','testname');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
[email protected]
denotes the mobilenumber@carrierdomain
.
When I execute this script. Output is that : Message sent!
But the sms is not received.
Please let me know if there is any mistake in my code (or) is it a invalid way to send SMS
using phpmailer
.
Using this code (change AddAddress field to email instead of mobile number) I can send mail.
But SMS cant be sent.
IS this possible to send SMS using phpmailer?
Please help me to resolve this problem.. Any help is greatly appreciated.
Upvotes: 1
Views: 7322
Reputation: 874
Seems that issue with 'ideacellular.net'. Most phone companies have an email gateway which permits you to send an SMS message to their customers via email. You'll need to determine for each service provider what that email address looks like and set up some code to turn their phone number and service provider combination into the appropriate email address.
Check this link: http://www.tech-recipes.com/rx/939/sms_email_cingular_nextel_sprint_tmobile_verizon_virgin/
Following code works with verizon
require 'class.phpmailer.php';
$mail = new PHPMailer();
// Configure SMTP
$mail->IsSMTP();
$mail->SMTPDebug = 2; // verbose information
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Encoding = '7bit';
// Auth
$mail->Username = "[email protected]";
$mail->Password = "password";
// Check
$mail->Subject = "Testing";
$mail->Body = "Testing";
$mail->AddAddress( "##########@vtext.com" );
var_dump( $mail->send() );
UPDATE
To send a text message from an email, you need to know the address for the SMS gateway. Below is a list of the SMS gateways for some of the major US cellular providers. If a carrier is not in the list, search the website for that carrier and you will likely find their SMS gateway address.
AllTel: [email protected]
AT&T: [email protected]
Boost Mobile: [email protected]
Cricket: [email protected]
Nextel: [email protected]
Qwest: [email protected]
Sprint: [email protected]
T-Mobile: [email protected]
Tracfone: [email protected]
U.S. Cellular: [email protected]
Verizon: [email protected]
Virgin Mobile: [email protected]
Also, you may check this link for the list of other providers: http://www.emailtextmessages.com/
Upvotes: 1