我需要帮助一个php联系表单脚本。问题是当我运行它时,我不会收到电子邮件,当我使用联系form.i希望有人可以告诉我问题所在位置找到下面的代码。我在测试PHP中运行它并得到此消息。我很感激,如果有人可以提供帮助
<php
/* Email Variables */
$emailSubject = 'indie music!';
$webMaster = 'myemail';
/* Data Variables */
$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=mydomain">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center"> message has been successfully sent you will be contacted shortly</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
答案 0 :(得分:0)
您是否将$webMaster
更改为有效的收件人电子邮件地址?
确保您在网络托管中运行这些脚本。 Localhost不执行PHP mail
函数。
如果您已经在网络托管上运行,请确保邮件不会进入垃圾邮件/垃圾邮件。