PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 15, 2022

[FIXED] How to send SMS from mail() function in PHP?

 January 15, 2022     php, phpmyadmin     No comments   

Issue

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


Solution

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.



Answered By - iLaYa ツ
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing