WP和PHP的新增功能:
我正在尝试用AJAX发送电子邮件。我的wp\\U邮件返回true,我在托管的GoDaddy上没有收到任何错误,但从未收到过该邮件。下面是我的php函数:
add_action("wp_ajax_send_email", "send_email");
add_action("wp_ajax_nopriv_send_email", "send_email");
function send_email() {
$to = "[email protected]";
$subject = "Hey";
$message = "Hello";
$headers = "From: [email protected]";
if (wp_mail($to, $subject, $message, $headers)) {
echo json_encode(array(\'status\' => \'success\', \'message\' => \'Contact message sent.\'));
exit;
} else {
echo json_encode(error_get_last());
}
}
我确实在JS中收到了成功消息。