我在index.php上有一个表格,如下所示:
<form name="order" method="Post" action="/postit.php" onSubmit="return
validate();"> Dear:<input type="edit" name="Dear__1" value=""
size="20" placeholder="">
Full Name:<input type="edit"
name="Full_Name__2" value="" size="20" placeholder="">
Billing Address: <textarea id="BILLINGADDRESS" name="Billing_Address__3"
cols="20" rows="2" placeholder=""></textarea>
然后在postit.php上我有这段代码
<?php
$to = 'My@email.com';
$subject = "YOUR ORDER dudse";
$htmlContent = file_get_contents("/postit.php");
// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: test<test@test.com>' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
?>
<!DOCTYPE HTML>
<html lan="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<p style="margin:0px;font-stretch:normal;font-size:18px;line-height:normal;font-family:sans-serif"><span>Dear: <?php echo $_POST['Dear__1'] ?>
</span></p>
<p style="margin:0px;font-stretch:normal;font-size:16px;line- height:normal;font-family:sans-serif"><span style="font-stretch:normal;font-size:18px;line-height:normal;font-family:"sans-serif Black"">Thank you</span><span> for your order!</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif;min-height:15px"><span></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif"><span>Please review this confirmation<b> </b></span><span style="text-decoration:underline"><b>very carefully</b></span><span><b>. </b>If there are any errors, please make me aware of them by return email, as production will begin to ensure prompt shipment just as soon as you approve this confirmation! </span><span style="color:rgb(102,0,0)"><b>For instance, check things like the style, color, height, grade, disclaimers, attachments, shipping address, etc. </b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:16px;line-height:normal;font-family:sans-serif;min-height:18px"><span><b></b></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:16px;line-height:normal;font-family:sans-serif"><span><b>If an attachment cannot be opened or a link cannot be accessed, please do not accept this confirmation.</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:14px;line-height:normal;font-family:sans-serif;min-height:16px"><span></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:18px;line-height:normal;font-family:sans-serif"><span><b>If all is correct</b> and you agree with the below terms and code disclaimer,<b> </b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:sans-serif"><span style="font-stretch:normal;font-size:18px;line-height:normal"><b>please reply to this email </b></span><span style="font-stretch:normal;font-size:18px;line-height:normal;color:rgb(102,0,0)"><b>"Accepted"</b></span><span style="font-stretch:normal;font-size:13px;line-height:normal"> </span><span>or otherwise affirm that you accept and agree to all terms in this order confirmation.</span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif;min-height:15px"><span></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif;color:rgb(12,52,61)"><span><b>Order Number</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif"><?php echo $CONFNUMBER ?></span></span></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:sans-serif;min-height:15px"><span></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Helvetica;color:rgb(0,51,51)"><span><b>Buyer</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12.8px;line-height:normal;font-family:sans-serif"><span><?php echo $_POST['Full_Name__2'] ?></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12.8px;line-height:normal;font-family:sans-serif"><span><?php echo nl2br($_POST['Billing_Address__3']);?>
<div><br></div></div>
</font></span>
</body>
</html>
Postit.php是我想用表格中的php变量发送的电子邮件模板。电子邮件发送文件中的所有html,但它不保留变量。当我提交表格时,他们都会显示出来。'