Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Sending a text message via php

    I've been using a friends code to send an sms message via php. The only issue is that on receiving the message it gives out the hosting servers name. Now this I know can lead to a security issue. So am I'm turning to you guys to see what is it that I've missed.

    This code uses the mail function of PHP
    The default sub is set to TestingText

    Here is the general form:
    Code:
     <form id="sms" name="sms" method="post" action="send.php">
    <table width="400">
      <tr>
        <td align="right" valign="top">From:</td>
        <td align="left"><input name="from" type="text" id="from" size="30" /></td>
      </tr>
      <tr>
        <td align="right" valign="top">To:</td>
        <td align="left"><input name="to" type="text" id="to" size="30" /></td>
      </tr>
      <tr>
        <td align="right" valign="top">Carrier:</td>
        <td align="left"><select name="carrier" id="carrier">
          <option value="verizon">Verizon</option>
          <option value="tmobile">T-Mobile</option>
       <option value="sprint">Sprint</option>
       <option value="att">AT&amp;T</option>
       <option value="virgin">Virgin Mobile</option>
        </select></td>
      </tr>
      <tr>
        <td align="right" valign="top">Message:</td>
        <td align="left"><textarea name="message" cols="40" rows="5" id="message"></textarea></td>
      </tr>
      <tr>
        <td colspan="2" align="right"><input type="submit" name="Submit" value="Submit" /></td>
        </tr>
    </table>
    </form>
    And here is the php code:

    Code:
     <?php
    $from = $_POST['from'];
    $to = $_POST['to'];
    $carrier = $_POST['carrier'];
    $message = stripslashes($_POST['message']);
    
    if ((empty($from)) || (empty($to)) || (empty($message))) {
    echo"Fail";
    }
    
    else if ($carrier == "verizon") {
    $formatted_number = $to."@vtext.com";
    mail("$formatted_number", "TestingText", "$message");
    
    echo"Success";
    }
    
    else if ($carrier == "tmobile") {
    $formatted_number = $to."@tomomail.net";
    mail("$formatted_number", "TestingText", "$message");
    
    echo"Success";
    }
    
    else if ($carrier == "sprint") {
    $formatted_number = $to."@messaging.sprintpcs.com";
    mail("$formatted_number", "TestingText", "$message");
    
    echo"Success";
    }
    
    else if ($carrier == "att") {
    $formatted_number = $to."@txt.att.net";
    mail("$formatted_number", "TestingText", "$message");
    echo"Success";
    }
    
    else if ($carrier == "virgin") {
    $formatted_number = $to."@vmobl.com";
    mail("$formatted_number", "TestingText", "$message");
    
    echo"Success";
    }
    ?>
    If anyone has any idea of cloaking the hosting servers name. Let me know please.
    Thanks all.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Do you mean as a default email address?
    The third example on the following link shows how to change the from address: http://php.ca/manual/en/function.mail.php
    You can also connect to different smtp servers by using custom socketing.
    You can clean the script up a little too, the empty function accepts any number of arguments, and use a switch to determine the to address. This will let you call mail only once.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •