让我的简单 php 电子邮件联系表正常工作时遇到问题。没有生成或返回错误,但我没有收到任何电子邮件。
这是我的表格http://bitstream.ca/beta2/contact.html
还有我正在使用的 php(当然还有我正确的电子邮件)
任何人都可以看到下面的表单代码有任何错误吗?有哪些一般的调试步骤可以尝试?提前致谢!
<?php
$errors = '';
$myemail = 'foo@foo.foo';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z {2,3})$/i", $email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
header('Location: contact-form-thank-you.html');
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>