lakeside12
Programmer
Hi
Below is the standard mail.php from a php mailer
Can you tell me why the SUBJECT fails to show up in the autoresponse e-mail that is set out. Instead I get the body of the mail sent in the subject
In the calling program I have the following
In the main mail program mail.php
Below is the standard mail.php from a php mailer
Can you tell me why the SUBJECT fails to show up in the autoresponse e-mail that is set out. Instead I get the body of the mail sent in the subject
In the calling program I have the following
Code:
<input name="recipient" type="hidden" value="my@mail.com" />
<input name="subject" type="hidden" value="test sub " />
<input name="required" type="hidden" value="email" />
<input name="errorpage" type="hidden" value="errorpage.html" />
<input name="redirect" type="hidden" value="ThankYou.php" />
<input name="autoresponse" type="hidden" value="autoresponse.html" />
<input name="mailsubject" type="hidden" value="test subject" />
<input name="autoresponsefrom" type="hidden" value="the test name" />
In the main mail program mail.php
Code:
<?php
if ($_POST[recipient] && $_POST[subject] && $_POST[redirect]) {
if ($_POST[required]) {
$rfields = explode (",",$_POST[required]);
foreach ($rfields as $check) {
if (!$_POST[$check]) {
header("Location: ".$_POST[errorpage]);
exit();
}
}
}
if ($_POST[autoresponse] && $_POST[email]) {
$html = file_get_contents($_POST[autoresponse]) or die("<b><font color=\"#ff0000\">Not a valid autoresponse page...</font><b>");
if ($html) {
$tit_start = strpos($html,"<title>")+7;
$tit_end = strpos($html,"</title>")-$tit_start;
$mailsubject = $html;
$mailsubject = substr($mailsubject, $tit_start, $tit_end);
mail($_POST[email], $mailsubject, $html, "From: $_POST[autoresponsefrom]<$_POST[recipient]>\r\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=iso-8859-1");
}
}
else if (!$_POST[email]) {
echo "<b><font color=\"#ff0000\">Email field required when using autoresponse mail...</font></b>";
exit();
}
$ndata = array("recipient","subject","required","errorpage","redirect","autoresponse","autoresponsefrom");
$postfields = $_REQUEST;
foreach ($postfields as $k => $v) {
if (in_array($k,$ndata)) unset($postfields[$k]);
else $msg .= $k.": ".$v."\n";
}
mail($_POST[recipient],$_POST[subject],$msg,"From: $_POST[email]\r\n"."Reply-To: $_POST[email]\r\n");
header("Location: ".$_POST[redirect]);
}
else echo "<b><font color=\"#ff0000\">Recipient, subject or redirect field is missing...</font></b>";
?>