从我的“联系我们”页面发送的电子邮件仅包含主题“联系我们页面消息来自”和正文消息的第一部分,例如来自:IGN:电子邮件:
似乎这些字段不起作用,但我不知道为什么。
这是我联系我们的 php 代码:
$mail_to = 'support@mineyc.com';
$subject = 'Contact Us page message from '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'IGN: '.$field_ign."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = '/contactus.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to support@mineyc.com');
window.location = '/contactus.html';
</script>
<?php
}
?>
这是HTML代码:
<!-- Main Content -->
<div class="container">
<div class="well">
<div class="row">
<div class="col-lg-6">
<div class="well">
<form class="form-horizontal" action="/php/contact.php" method="post">
<fieldset>
<legend>Contact Us</legend>
<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputName" placeholder="Name">
</div>
</div>
<div class="form-group">
<label for="inputIGN" class="col-lg-2 control-label">IGN</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputIGN" placeholder="In-game Name">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Message</label>
<div class="col-lg-10">
<textarea class="form-control" rows="3" id="textArea"></textarea>
<span class="help-block">Please enter a real email address so that we can reply to your message.</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
一定是某个地方出现了一些小错误,或者我在 HTML 中遗漏了一些东西。提前感谢您的帮助。