【问题标题】:Send SMS to cellphone using phpmailer使用 phpmailer 向手机发送短信
【发布时间】:2015-11-18 07:14:37
【问题描述】:

我正在尝试通过我的 gmail 帐户使用 phpmailer 发送 SMS

这是我的代码:

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

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

但是没有收到短信。

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

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

但是无法发送短信。

是否可以使用 phpmailer 发送短信?

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

【问题讨论】:

  • phpmailer 仅用于电子邮件...通常第三方 SMS 插件需要付费
  • 邮件是否转发到手机?
  • 不,电子邮件发送到电子邮件ID(如果我提供电子邮件ID),但我想向手机发送消息(如果我提供手机号码)

标签: php gmail sms phpmailer sms-gateway


【解决方案1】:

似乎与“ideacellular.net”有关。 大多数电话公司都有​​一个电子邮件网关,允许您通过电子邮件向他们的客户发送 SMS 消息。您需要确定每个服务提供商的电子邮件地址是什么样的,并设置一些代码将他们的电话号码和服务提供商组合转换为适当的电子邮件地址。

检查此链接: 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 网关列表。如果运营商不在列表中,请在网站上搜索该运营商,您可能会找到他们的 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/

【讨论】:

  • 只知道手机号码怎么知道服务商的邮箱?
  • 我刚刚更新了帖子。检查它是否可以帮助你。
猜你喜欢
  • 1970-01-01
  • 2012-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多