我不太了解 PHP,正在尝试获取一个非常简单的 PHP 脚本来发送电子邮件。单击提交时,我收到了谢谢消息,但没有电子邮件。
<?php $name = $_POST['name'];
$email = $_POST['email'];
$web = $_POST['web'];
$message = $_POST['message'];
$formcontent="From: $name \n Website: $web \n Message: $message";
$recipient = "myemail@example.com"; // I do have my email here
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
这是html表单:
<form action="mail.php" method="post" class="form">
<p class="name">
<label for="name">Name</label>
<input type="text" name="name" id="name" />
</p>
<p class="email">
<label for="email">E-mail</label>
<input type="text" name="email" id="email" />
</p>
<p class="web">
<label for="web">Website</label>
<input type="text" name="web" id="web" />
</p>
<p class="text">
<label for="web">Comments</label>
<textarea name="message"></textarea>
</p>
<p class="submit">
<input type="submit" value="Send" />
</p>
</form>