我目前正在开发一个使用 PHP 将消息发送到电子邮件的 HTML 表单。我正在 MAMP 中进行测试,单击“发送消息”后无法得到响应。任何建议将不胜感激。
HTML
<form action="mail.php" method="POST">
<div class="row half">
<div class="6u">
<input type="text" class="text" name="name" placeholder="Name" />
</div>
<div class="6u">
<input type="text" class="text" name="email" placeholder="Email" />
</div>
</div>
<div class="row half">
<div class="12u">
<textarea name="message" placeholder="Message" rows="6" cols="25"></textarea>
<br />
</div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li class="button form" input type="submit" value="Submit">Send Message</li>
</ul>
</div>
</div>
</form>
PHP
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$to = 'my@email.com';
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
$send_message=mail($to, $subject, $formcontent, $mailheader);
if($send_message){
echo "thank you"
} else {
echo "error";
}
?>
谢谢