doulu1945 2012-10-10 09:37
浏览 60
已采纳

如何从PHP中的mail()函数发送短信?

Here is my code in php for sending sms

   if(isset($_POST['frmType'])&& $_POST['frmType'] == "guest_mail"){
        $from = $_POST['from'];
        $to = $_POST['to'];
        $carrier = $_POST['carrier'];
        $message = stripslashes($_POST['message']);

        if ((empty($from)) || (empty($to)) || (empty($message))) {
        echo"<br/>".$from;
        echo"<br/>".$to;
        echo"<br/>".$message;
        }

        else if ($carrier == "Verizon" || $carrier == "verizon") {
        $formatted_number = $to."@vtext.com";
        mail("$formatted_number", "", "$message");

        echo"<script type=text/javascript>abc();</script>"; 
        }

        else if ($carrier == "T-Mobile" || $carrier == "tmobile" || $carrier == "Tmobile") {
        $formatted_number = $to."@tomomail.net";
        mail("$formatted_number", "", "$message");

        echo"<script type=text/javascript>abc();</script>"; 
        }
    }

Instead of mail function i have used 5 type of script for mail function

1. mail('$formatted_number','','$message');

2. mail('$formatted_number','','$message','$from');

3. mail('$formatted_number','$subject','$message','$from');

4. mail('$formatted_number','$subject','$message');

5. mail("$formatted_number", "SMS", "$message"); 

But still my SMS is not deliver to my brother

I refer the following link for sending the sms

http://www.ehow.com/how_7300418_send-sms-using-php.html

http://www.daniweb.com/web-development/php/code/291287/send-text-messages-with-php

http://www.textmessagetool.com/php_sms_script.php

But still it's not working.

I don't understand what exactly problem is?

Please help

Thanks in advance

  • 写回答

3条回答 默认 最新

  • duancuan7057 2012-10-10 09:48
    关注

    To send SMS you need carriers. For that you need to register with some third party API provider's website, so they will provide an API. Using that API you can send the SMS.

    If you want to send SMS using PHP mail function then you need to have address for the network’s SMS Gateway.

    phone_umber(unique)@domainname.com 
    

    Based on the mobile network the domain name will change. There are lists of SMS gateways.

    Say example, you want to send a text to Mr. X, you could simply add 3855550168@vtext.com to any email client, type a message and hit send. This will send a text message to phone number +1 (385) 555-0168 on the Verizon Wireless Network.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献