这是我的代码。我无法显示错误信息。只是不发送邮件。这种方法有什么问题?
<a id="target" href="http://www.mylink.wav">mylink</a>
<script type="text/javascript">
$(function() {
$("#target").mousedown(function() {
$.post(
"sendemail.php",
{ name: "John" }
);
});
});
</script>
<?php
if($_POST)
{
$mail = "myemail.email.com"
$name = $_POST['name'];
$subject = 'My subject';
$to = "myemail@email.com";
$message = "My message: ".$name."<br />";
$headers = "From: $mail 'n";
$headers .= "Reply-To: $mail 'n";
$headers .= "MIME-Version: 1.0 'n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 'n";
}
?>
感谢您对解决这个问题的建议
首先检查是否在jQuery块中调用脚本。
第二,您需要包含phpmail()
函数(如果在服务器上启用):
mail($to, $subject, $message, $headers);
http://php.net/manual/en/function.mail.php