我已经设置了一个 PHP 邮件表单,它只正确输出表单中输入的一些变量。它确实发送 $name 和 $email 变量,但不发送 $message 变量。
发送表单的 php 在这里:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST" ){
$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$message = trim($_POST["message"]);
//sending email
require_once("siteIncludes/class.phpmailer.php");
$mail = new PHPMailer();
$email_body = "";
$email_body = $email_body . "Name: " . $name . $message . "<br />";
$email_body = $email_body . "Email: " . $email . "<br />";
$email_body = $email_body . "Message: " . $message;
$mail->SetFrom("$email,$name");
$address = "foo@bar.com";
$mail->AddAddress($address);
$mail->Subject = "Form Submission | ".$name;
$mail->MsgHTML($email_body);
if(!$mail->Send() ){
echo 'There was a problem sending the email: '.$mail->ErrorInfo;
exit();
}
header("Location: myContact.php?status=thanks");
exit();
};
?>
设置表单的 HTML 在这里:
<div id="contactFormWrap" class="span6 offset3">
<form method="post" action="myContact.php" id="contactForm">
<div>
<label for="name">Please leave your name</label>
<input type="text" name="name" id="name" value="" class="required" />
</div>
<div>
<label for="email">and your email</label>
<input type="text" name="email" id="email" value="" class="required email" />
</div>
<div>
<label for="subject">What is your message about?</label>
<input type="text" name="subject" id="subject" value="" class="required" />
</div> -->
<div>
<label for="message">and your message</label>
<textarea name="message" id="message" value="" rows="10" class="required"></textarea>
</div>
<div id="messageButtons">
<input type="submit" value="Submit" name="contactSubmit" id="contactSubmit" class="sendEmail btn" />
</div>
</form>
</div>
我希望这是足够的信息。有谁知道为什么 $message 变量没有输出到提交的电子邮件?
谢谢