doudai3012 2015-10-09 00:26
浏览 104

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

I am trying to send sms messages with php. My code works with regular text mesages I can read and reply. but sms messages the reply address shows up as an address to the server and I can't reply. Any help is greatly appreciated. Would also be interested if anyone knows if I can send an imessage using this script.

      <!--  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 

$headers = "From: $email
Reply-To: $email";
//add boundary string and mime type specification
$headers .= "
Content-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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 虚心请教几个问题,小生先有礼了
    • ¥30 截图中的mathematics程序转换成matlab