我正在使用一个模板来创建我的网站,它带有一个联系页面和所有表格,但它没有一个 php 联系脚本,所以我写了它并将其设置为 html 表单上的操作,它仍然赢了'不要向我的电子邮件发送任何内容......我通过 gmail 设置(我将域电子邮件交换 DNS 更改为 gmail 设置)在 html 联系表单中我有以下代码:
<div id="contact_form"><form method="post" name="contact" action="contact-form-handler.php">
<label for="name">Name:</label> <input type="text" id="name" name="name" class="required input_field" /><div class="cleaner h10"></div>
<label for="email">Email:</label> <input type="text" id="email" name="email" class="validate-email required input_field" /><div class="cleaner h10"></div>
<label for="subject">Subject:</label> <input type="text" name="subject" id="subject" class="input_field" /><div class="cleaner h10"></div>
<label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea><div class="cleaner h10"></div>
<input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" />
<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
</form>
并且 contact-form-handler.php 包含以下代码来处理 html 表单:
<?php
$to = 'info@jamesreborne.co.uk';
$to .= 'damgxx@gmail.com';
// Assigning data from the $_POST array to variables
$name = $_post['sender_name'];
$email = $_post['sender_email'];
$subject = $_post['sender_subject'];
$text = $_post['sender_text'];
// Construct email subject
$content = 'www.jamesreborne.co.uk Message from visitor ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $email. "\r\n";
$body_message .= 'Subject: ' . $subject . "\r\n";
$body_message .= 'Message: ' . $text;
// Construct email headers
$headers = 'From: ' . $email . "\r\n";
$headers .= 'Reply-To: ' . $email . "\r\n";
mail($to, $content, $body_message, $headers);
$mail_sent = mail($to, $content, $body_message, $headers);
if ($mail_sent == true){ ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php }
else { ?>
<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify the site administrator info@jamesreborne.co.uk');
window.location = 'contact.html';
</script>
<?php
}
?>
如果有人可以提供帮助,那就太好了,谢谢