为什么WP阻止我发送邮件?
我创建了一个文件mail.php并测试了PHP mail():
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
我将它上传到我的服务器,在根目录中。我运行它,然后收到了电子邮件。
但是当我使用
时$message = trim($_POST['sender_message']);
$email = trim($_POST['sender_email']);
//php mailer variables
$to = get_option('admin_email');
$subject = "Someone sent a message from ". get_bloginfo('name') . ": " . $subject;
$headers = 'From: '. $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
// $sent = wp_mail($to, $subject, strip_tags($message), $headers);
$sent = mail($to, $subject, strip_tags($message), $headers);
var_dump($send); // bool true
if($sent) {
// do something
}
我在var_dump检查中得到bool true。但我从未收到服务器发来的任何电子邮件。
有什么想法吗?我错过了在WP中配置的内容吗?
修改
服务器不会从 yahoo 帐户发送任何电子邮件!为什么???
$to = "xxx@yahoo.co.uk"; // works!
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: bbb@yaho.co.uk" . "\r\n" . // won't work!
"CC: lau.tiamkok@gmail.com";
mail($to,$subject,$txt,$headers);