使用phpmailer发送短信到手机

时间:2015-11-18 07:14:37

标签: php gmail sms phpmailer sms-gateway

我正在尝试使用 phpmailer gmail 帐户发送短信

这是我的代码:

require_once('../class.phpmailer.php');

$mail             = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "tls";
$mail->Username   = "myusername@gmail.com";
$mail->Password   = "mypassword";
$mail->Host       = "smtp.gmail.com";
$mail->Port       = 587;

$mail->SetFrom('myusername@gmail.com', 'DS');
$mail->Subject    = 'hello';
$mail->Body    = 'this is a testing mail..';
$mail->AddAddress('xxxxxxxxxx@ideacellular.net','testname');

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

xxxxxxxxxx@ideacellular.net表示mobilenumber@carrierdomain

当我执行此脚本时。输出是:发送消息!

但没有收到短信。

如果我的代码(或)中有任何错误,请告诉我使用SMS发送phpmailer的方式无效。

使用此代码(将AddAddress字段更改为电子邮件而不是手机号码)我可以发送邮件。

但短信无法发送。

这可以使用phpmailer发送短信吗?

请帮我解决这个问题.. 非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

似乎与'ideacellular.net'存在问题。 大多数电话公司都有​​一个电子邮件网关,允许您通过电子邮件向其客户发送短信。您需要为每个服务提供商确定该电子邮件地址的外观,并设置一些代码以将其电话号码和服务提供商组合转换为相应的电子邮件地址。

sms-php

检查此链接: http://www.tech-recipes.com/rx/939/sms_email_cingular_nextel_sprint_tmobile_verizon_virgin/

以下代码适用于verizon

要求'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.address@gmail.com"; 
$mail->Password   = "password"; 

// Check
$mail->Subject = "Testing";     
$mail->Body = "Testing";        


$mail->AddAddress( "##########@vtext.com" ); 
var_dump( $mail->send() );  

<强>更新

要从电子邮件发送短信,您需要知道SMS网关的地址。以下是一些美国主要移动电话提供商的SMS网关列表。如果运营商不在列表中,请在网站上搜索该运营商,您可能会找到他们的短信网关地址。

AllTel: number@message.alltel.com
AT&T: number@txt.att.net
Boost Mobile: number@myboostmobile.com
Cricket: number@sms.mycricket.com
Nextel: number@messaging.nextel.com
Qwest: number@qwestmp.com
Sprint: number@messaging.sprintpcs.com
T-Mobile: number@tmomail.net
Tracfone: number@mmst5.tracfone.com
U.S. Cellular: number@email.uscc.net
Verizon: number@vtext.com
Virgin Mobile: number@vmobl.com

此外,您可以查看此链接以获取其他提供商的列表: http://www.emailtextmessages.com/

相关问题