我在我的网站上整理了一个简单的PHP联系表单。 当我提交消息时,它会发送消息。 但我没有收到电子邮件。
我正在使用的代码位于
之下<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
<div class="field half first">
<label for="name">Name</label>
<input name="name" id="name" type="text" placeholder="Name">
</div>
<div class="field half">
<label for="email">Email</label>
<input name="email" id="email" type="email" placeholder="Email">
</div>
<div class="field">
<label for="message">Message</label>
<textarea name="message" id="message" rows="6" placeholder="Message"></textarea>
</div>
<ul class="actions">
<li><input value="Send email" class="button alt" type="submit"></li>
</ul>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("xyz@website.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
为谷歌应用设置MX记录,这与电子邮件未被发送的原因有关吗?