PHP表单不向指定地址发送电子邮件
我的网站上有一张联系表,突然电子邮件停止了。我已经检查了主机和网络邮件,一切正常(我甚至张贴到不同的电子邮件地址)。所以我假设联系表不知怎么坏了,因为当我发送消息时,我们什么也没有收到。我对PHP有点生疏。如果有人知道一种更好的方法来编写代码,我们将不胜感激PHP表单不向指定地址发送电子邮件,php,forms,post,html-email,Php,Forms,Post,Html Email,我的网站上有一张联系表,突然电子邮件停止了。我已经检查了主机和网络邮件,一切正常(我甚至张贴到不同的电子邮件地址)。所以我假设联系表不知怎么坏了,因为当我发送消息时,我们什么也没有收到。我对PHP有点生疏。如果有人知道一种更好的方法来编写代码,我们将不胜感激 <?php include ('includes/config.php'); $error = array(); $name = ''; $email = ''; $telephone = ''; $message = ''; if
<?php
include ('includes/config.php');
$error = array();
$name = '';
$email = '';
$telephone = '';
$message = '';
if (isset($_POST['Send']))
{
// Assign form data
$name = $_POST['Name'];
$email = $_POST['Email'];
$telephone = $_POST['Telephone'];
$message = $_POST['Message'];
// Check for errors
if (empty($name)) { $error[] = 'Name'; }
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { $error[] = 'Email'; }
if (empty($telephone)) { $error[] = 'Telephone'; }
if (empty($message)) { $error[] = 'Message'; }
// If no errors
if (sizeof($error) < 1) {
// Build message
$message = "Name: $name \n Email: $email \n Telephone: $telephone \n" . $message;
// Send email
mail('info@EXAMPLE.co.uk', "Example Message From $name", $message);
// Reset form
$name = '';
$email = '';
$telephone = '';
$message = '';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Us | <?=SITE_NAME?></title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include ('includes/header.php'); ?>
<div id="wrapper">
<div id="main">
<h1>Contact Us</h1>
<?php
if (sizeof($error) > 0)
{
echo '<p>There were errors for the following fields:</p><ul>';
foreach ($error as $val) {
echo "<li>$val</li>";
}
echo '</ul>';
}
else
{
echo '<p>Thank you for contacting us, we will get back to you shortly.</p>';
}
?>
<table cellpadding="5" cellspacing="0">
<form method="post" action="">
<tr>
<td width="150"><label for="Name">Name: </label></td>
<td><input type="text" name="Name" value="<?=$name?>" /></td>
</tr>
<tr>
<td><label for="Email">Email: </label></td>
<td><input type="text" name="Email" value="<?=$email?>" /></td>
</tr>
<tr>
<td><label for="Telephone">Telephone: </label></td>
<td><input type="text" name="Telephone" value="<?=$telephone?>" /></td>
</tr>
<tr>
<td valign="top"><label for="Message">Message: </label></td>
<td><textarea name="Message" rows="10" cols="55"><?=$message?></textarea></td>
</tr>
<tr>
<td></td>
<td><button type="submit" name="Send">Send Message</button></td>
</tr>
</form>
</table>
</div>
<?php include ('includes/footer.php'); ?>
</div>
</body>
</html>
联系我们|
联系我们
姓名:
“突然”意味着他们以前使用过这个确切的代码?假设错误日志是安静的,您是否考虑过在接收端进行过滤的可能性?您使用的是邮件
,这是一种非常基本的电子邮件发送方式。在某些系统上,它缺少一些可以帮助您的邮件收件箱的功能。@RoAchterberg是的,所有电子邮件,甚至其他形式的通知电子邮件都已停止。上面的代码正是以前的代码。所以我不确定问题可能是什么。这是一个长期的机会,但检查您的IP是否已被列入黑名单?如果它以前工作正常,并且停止时没有显示错误,那么这可能就是问题所在。