由于PHP邮件已在我的服务器上禁用,因此它已停止主题集成联系表单的工作。在Wordpress中使用wp_mail()代替邮件()不起作用
这个主题叫做Boldy,它有它自己的sendmail.php文件,它使用mail()
而不是wp_mail()
。
将mail()
更改为wp_mail()
不起作用,但我不知道为什么?
<?php
if (isset($_POST['submit']))
{
error_reporting(E_NOTICE);
function valid_email($str)
{
return (! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if ($_POST['name'] != '' && $_POST['email'] != '' && valid_email($_POST['email']) == TRUE && strlen($_POST['comment']) > 1)
{
$to = preg_replace("([\r\n])", "", $_POST['receiver']);
$from = preg_replace("([\r\n])", "", $_POST['email']);
$subject = "Website contact message from ".$_POST['name'];
$message = $_POST['comment'];
$match = "/(bcc:|cc:|content\-type:)/i";
if (preg_match($match, $to) || preg_match($match, $from) || preg_match($match, $message))
{
die("Header injection detected.");
}
$headers = "From: ".$from."\r\n";
$headers .= "Reply-to: ".$from."\r\n";
if (mail($to, $subject, $message, $headers))
{
echo 1; //SUCCESS
}
else
{
echo 2; //FAILURE - server failure
}
}
else
{
echo 3; //FAILURE - not valid email
}
}
else
{
die("Direct access not allowed!");
}
?>
这是否解决?我现在遇到了同样的问题,我的网站...任何帮助表示赞赏。 – jaressloo 2012-05-20 05:29:16