ok here is the second part of PHP mailer script (this PHP file is called by a form)
My question is, for some reason I can get the email sent to some one from someone, but I cant get it to reply to someone else! All of these variables are defined in the previous form
-----------------------------------------------------------------------------------------------------------------------------------
<html>
<head><title>Anonymous Email</title><link rel="stylesheet" type="text/css" href="style.css" /></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$to = $HTTP_POST_VARS['to'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$from = $HTTP_POST_VARS['from'];
$repl = $HTTP_POST_VARS['reply'];
$reply = "-f"+$repl+"";
$headers = ""+$from+"\r\n
Reply-To:"+$repl+"\r\n
Return-Path: "+$repl+"\r\n
'Content-type: text/html\r\n'";
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $to)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from)) {
echo "<div><h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a></div>";
} elseif ($subject == "") {
echo "<div><h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a></div>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($to,$subject,$message,"From: $from\r\n" )) {
echo "<div><h4>Thank you for sending email</h4><br /><a href='javascript:history.back(1)'>Go back</a></div>";
} else {
echo "<div><h4>Can't send email to $email</h4><br /><a href='javascript:history.back(1)'>Go back</a></div>";
}
?>
</body>
</html>
My question is, for some reason I can get the email sent to some one from someone, but I cant get it to reply to someone else! All of these variables are defined in the previous form
-----------------------------------------------------------------------------------------------------------------------------------
<html>
<head><title>Anonymous Email</title><link rel="stylesheet" type="text/css" href="style.css" /></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$to = $HTTP_POST_VARS['to'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$from = $HTTP_POST_VARS['from'];
$repl = $HTTP_POST_VARS['reply'];
$reply = "-f"+$repl+"";
$headers = ""+$from+"\r\n
Reply-To:"+$repl+"\r\n
Return-Path: "+$repl+"\r\n
'Content-type: text/html\r\n'";
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $to)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from)) {
echo "<div><h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a></div>";
} elseif ($subject == "") {
echo "<div><h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a></div>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($to,$subject,$message,"From: $from\r\n" )) {
echo "<div><h4>Thank you for sending email</h4><br /><a href='javascript:history.back(1)'>Go back</a></div>";
} else {
echo "<div><h4>Can't send email to $email</h4><br /><a href='javascript:history.back(1)'>Go back</a></div>";
}
?>
</body>
</html>