我想借助php通过html表单发送电子邮件。但是,它保持 每次声称找不到php文件时都抛出相同的错误。我试过了 一切:
根本没有运气。
仍然为POST /mail.php Error (404): "Not found"
。我在这里想念什么?
您可以在系统上使用它吗?
HTML:
<form name="contactform" method="POST" action="mail.php">
<div>
<input type="text" name="user_name" placeholder="name" required />
<input type="email" name="user_email" placeholder="email" required />
<textarea type="text" name="comments" placeholder="message" required></textarea>
</div>
<button type="submit">SEND</button>
</form>
PHP:
<?php
$name = $_POST['user_name'];
$email = $_POST['user_email'];
$message = $_POST['comments'];
$formcontent=" From: $name \n Message: $message";
$recipient = "********@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
答案 0 :(得分:0)
使用此:-
<form name="contactform" method="POST" action="mail.php">
<input type="text" name="user_name" id="user_name" placeholder="name" required />
<input type="email" name="user_email" id="user_email" placeholder="email" required />
<textarea type="text" name="comments" id="comments" placeholder="message" required></textarea>
<input type="submit" id="submit" value="SEND" />
</form>