我目前正在处理联系表单,它似乎正在通过,但我没有收到电子邮件。我不确定问题是什么。我猜它在我的PHP中,但我没有看到问题出在哪里。
HTML标记:
<form method="post" id="contact" class="peThemeContactForm" action="mail.php">
<div id="personal" class="bay form-horizontal">
<div class="control-group"><!--name field-->
<div class="controls">
<input class="required span9" type="text" name="author" data-fieldid="0" value="Full Name" onclick="if(this.value=='Full Name') this.value=''" onblur="if(this.value=='') this.value='Full Name'">
</div>
</div>
<div class="control-group"><!--email field-->
<div class="controls">
<input class="required span9" type="email" name="email" data-fieldid="1" value="Your Email" onclick="if(this.value=='Your Email') this.value=''" onblur="if(this.value=='') this.value='Your Email'">
</div>
</div>
<div class="control-group"><!--message field-->
<div class="controls">
<textarea name="message" rows="12" class="required span9" data-fieldid="2" onclick="if(this.value=='Type Message') this.value=''" onblur="if(this.value=='') this.value='Type Message'">Type Message</textarea>
</div>
</div>
<div class="control-group">
<div class="controls send-btn">
<button type="submit" class="contour-btn red">Send Message</button>
</div>
</div>
</div>
<div class="notifications">
<div id="contactFormSent" class="formSent alert alert-success">
<strong>Your Message Has Been Sent!</strong> Thank you for contacting us.</div>
<div id="contactFormError" class="formError alert alert-error">
<strong>Oops, An error has ocurred!</strong> See the marked fields above to fix the errors.</div>
</div>
</form>
PHP:
<?php
if(isset($_POST['email'])){
$mailTo = "jake_ols@live.com";
$subject = "mail from web";
$body = "New message from web
<br><br>
FROM: ".$_POST['email']."<br>
NAME: ".$_POST['author']."<br>
COMMENTS: ".$_POST['message']."<br>";
$headers = "To: Jake <".$mailTo.">\r\n";
$headers .= "From: ".$_POST['author']." <".$_POST['email'].">\r\n";
$headers .= "Content-Type: text/html";
//envio destinatario
$mail_success = mail($mailTo, utf8_decode($subject), utf8_decode($body), $headers);
}
?>
答案 0 :(得分:1)
您最有可能的回答是服务器没有启用邮件
使用phpinfo()查找您应该编辑哪个ini文件,并确保您已将php服务器设置为发送邮件。
; For Win32 only.
sendmail_from = me@example.com
或者使用SMTP并连接到Mailgun https://documentation.mailgun.com/quickstart-sending.html#send-via-smtp
等服务