我正在尝试向我的电子邮件地址'iamhamzach@gmail.com'发送反馈消息,脚本运行正常,但我没有收到电子邮件。请告诉我这是什么问题..
HTML:
<html>
<body>
<form action="email.php" method="post">
<input type="text" id="name" value="name" name="name"/><br>
<input type="text" id="email" value="email" name="email"/><br>
<input type="text" id="comment" value="comment" name="comment"/><br>
<input type="submit" value="submit"/>
</form>
</body>
</html>
PHP:
<?php
$emailSubject = 'my first mail';
$webMaster = 'iamhamzach@gmail.com';
$emailField = $_POST['email'];
$nameField = $_POST['name'];
$commentField = $_POST['comment'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Comments: $comment <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
<html>
<body>
Thank you for your feed back
</body>
</html>
EOD;
echo "$theResults";
?>
答案 0 :(得分:2)
大多数localhosts都不支持开箱即用的电子邮件。
尝试将此脚本上传到您的webhost,它应该没问题。
代码看起来不错。