Я пытаюсь отправить смс сообщения с php. Мой код работает с обычными текстовыми сообщениями, которые я могу прочитать и ответить. но в сообщениях смс адрес ответа отображается как адрес сервера, и я не могу ответить. Любая помощь с благодарностью. Также было бы интересно, если кто-нибудь знает, могу ли я отправить сообщение с помощью этого сценария.
<!-- 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="[email protected]">
<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 [email protected] 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 [email protected]>AT&T</option>
<option [email protected]>Alltel</option>
<option [email protected]>Boost</option>
<option [email protected]>Cingular</option>
<option [email protected]>Cricket Wireless</option>
<option [email protected]>Nextel</option>
<option [email protected]>Sprint</option>
<option [email protected]>T-Mobile USA</option>
<option [email protected]>Verizon Wireless</option>
<option [email protected]>Virgin Mobile USA</option>
<option [email protected]>AT&T Multimedia</option>
<option [email protected]>Alltel Multimedia</option>
<option [email protected]>Sprint Multimedia</option>
<option [email protected]>Verizon Wireless Multimedia</option>
<option [email protected]>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
?>
Задача ещё не решена.
Других решений пока нет …