我在家里有发送电子邮件的功能。php wordpress文件和函数如下
$("#sendmailbtn").click(function(e) {
var dataString = $(".pricing").html();
e.preventDefault();
var grandTotal = localStorage.getItem("GrandTotal");
$.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
datatype: "html",
data: {\'action\': \'fahadsending_mail\', \'more\': dataString, \'grandTotal\': grandTotal},
success: function(response) {
alert("success is " + response);
},error:function(response){
alert("error is " + response);
}
});
});
以及我函数中的电子邮件代码。php文件在下面,我正在向fahadsending\\u邮件函数发送帖子,但它是ajax成功函数,它警告成功是0
add_action(\'wp_ajax_fahadsending_mail\', \'fahadsending_mail\');
add_action(\'wp_ajax_fahadsending_mail\', \'fahadsending_mail\');
function fahadsending_mail(){
$to = "[email protected]";
$subject = "Donation";
$message = "message message message message message message message ";
if(wp_mail($to, $subject, $message))
{
echo "mail sent";
} else {
echo "mail not sent";
}
}
响应出现在成功函数中,它的警报成功为0,ajax post显示以下操作wplc\\u call\\u to\\u server\\u visitor cid 213 security2f40c8e66f status5 wplc\\u emailno email set wplc\\u nameGuest wplcsession 1456325128583