发送短信息,PHP返回地址不起作用

时间:2015-10-09 00:26:42

标签: php sms imessage

我正在尝试使用php发送短信。我的代码适用于我可以阅读和回复的常规文本消息。但短信回复地址显示为服务器的地址,我无法回复。任何帮助是极大的赞赏。如果有人知道我是否可以使用此脚本发送imessage,也会感兴趣。

      <!--  Start HTML content -->
<html>
<head>
<title>Send Free Text SMS Messages Online</title>
    <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
    <META NAME="AUTHOR" CONTENT="rrolleston@roadrunner.com">
    <META NAME="CREATED" CONTENT="0;0">
    <META NAME="CHANGEDBY" CONTENT="Robert Rolleston">
    <META NAME="CHANGED" CONTENT="20110330;11192500">
    <META NAME="DESCRIPTION" CONTENT="free sms, free text messages, send free sms, send sms, free sms messaging, iphone text, mms, nextel text messaging, verizon text messages, tmobile text messaging, cell nokia phone, cellphone ringtone, cell cingular phone">
    <META NAME="KEYWORDS" CONTENT="Send Free Text Messages. Send free sms and mms worldwide. Add a text-messaging tool to your myspace or website.">
    <META NAME="robots" CONTENT="index,follow,archive">
</head>
<body>
<center><script type="text/javascript"><!--
google_ad_client = "ca-pub-9082831830250358";
/* sms4free */
google_ad_slot = "5369285945";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>

<?php

// ==============
// Configuration
// ==============
$uploaddir = "../upload";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$privatekey = "";
// Private Capcha Key
$publickey = "";
// Public Capcha Key

// ==============
// Variables
// ==============
    $ip = $_SERVER['REMOTE_ADDR'];
    $timestamp = date("r", time() + 60 * 60 * 2);

    $number = trim($_POST['number']);
    $carrier = $_POST['carrier'];

    $email = $_POST['email'];
    $sms = $number.$carrier;   
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    $email = Trim(stripslashes($_POST['email'])); 
    $sms = Trim(stripslashes($sms)); 
    $subject = Trim(stripslashes($_POST['subject'])); 
    $fname = Trim(stripslashes($_POST['fname'])); 
    $lname = Trim(stripslashes($_POST['lname'])); 
    $message = Trim(stripslashes($_POST['message'])); 
    $file = $_FILES['file']['name'];

    $email = $fname.' '.$lname.' <'.$email.'>';

if(isset($_POST['send'])) {

  require_once('recaptchalib.php');

  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {

// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}
$attachment_file = $_FILES['file'];
$attachment_dir = $uploaddir.'/'.$_FILES['file']['name'];

//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: $email\r\nReply-To: $email";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents($attachment_dir)));
//define the body of the message.

ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?> 
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"

--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<?php echo $message; ?> 

--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<?php echo $message; ?> 

--PHP-alt-<?php echo $random_hash; ?>--

--PHP-mixed-<?php echo $random_hash; ?> 
Content-Type:   application/octet-stream; name="<?php echo $_FILES['file']['name']; ?>" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment; filename="<?php echo $_FILES['file']['name']; ?>"

<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
@
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email

$mail_sent = @mail( $sms, $subject, $message, $headers );
//if the message is sent successfully print "Message sent". Otherwise print "Message failed"
echo $mail_sent ? "Text SMS Message Sent Successfully" : "Text SMS Message failed";

}
}

// Get Data Using a Form
?>
<center>
<form method="post" action="test.php" enctype="multipart/form-data">
        <?php
          require_once('recaptchalib.php');

          echo recaptcha_get_html($publickey);
        ?>
<table width="200">
  <tr>
<center>Send free text and sms picture messages to just about any carrier and you will be able to get their replies in your email.  We are currently working to improve this service you can contact me at rrolleston@roadrunner.com about any problems or suggestions.
  </tr>
  <tr>
    <td align="right" valign="top">Your E-Mail:</td>
    <td align="left"><input name="email" type="text" id="email" size="30" /></td>
  </tr>
  <tr>
    <td align="right" valign="top">First Name:</td>
    <td align="left"><input name="fname" type="text" id="fname" size="30" /></td>
  </tr>
  <tr>
    <td align="right" valign="top">Last Name:</td>
    <td align="left"><input name="lname" type="text" id="lname" size="30" /></td>
  </tr>
  <tr>
    <td align="right" valign="top">Subject:</td>
    <td align="left"><input name="subject" type="text" id="subject" size="30" /></td>
  </tr>
  <tr>
    <td align="right" valign="top"></td>
    <td>
     <p style="text-align:left">Recipient's 10 digit #:
     <input name=number type=text id=number size=12 maxlength=50> @ 
<p style="text-align:left">Carrier:
      <select name=carrier id=carrier>
    <option>-=Select A Carrier=-</option>
        <option value=@txt.att.net>AT&T</option>
        <option value=@message.alltel.com>Alltel</option>
        <option value=@myboostmobile.com>Boost</option>
        <option value=@mobile.mycingular.com>Cingular</option>
        <option value=@sms.mycricket.com>Cricket Wireless</option>
        <option value=@messaging.nextel.com>Nextel</option>
        <option value=@messaging.sprintpcs.com>Sprint</option>
        <option value=@tmomail.net>T-Mobile USA</option>
        <option value=@vtext.com>Verizon Wireless</option>
        <option value=@vmobl.com>Virgin Mobile USA</option>
        <option value=@mms.att.net>AT&T Multimedia</option>
        <option value=@mms.alltel.net>Alltel Multimedia</option>
        <option value=@pm.sprint.com>Sprint Multimedia</option>
        <option value=@vzwpix.com>Verizon Wireless Multimedia</option>
        <option value=@page.nextel.com>Nextel Multimedia</option>
      </select><br>
If you don't see a mobile carrier you need please contact us.
    </p></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 align="right" valign="top">Upload File:</td>
    <td align="left"><input type="file" name="file"></td>
  </tr>
  <tr>
    <td colspan="2" align="right"><input name="send" type="submit" id="send" value="Send"></td>
    </tr>
</table>
</form>
      <!-- more of your HTML content -->
    </body>
  </html>
<?php

?>

0 个答案:

没有答案