Why WP prevent me from sending mail?
I created a file mail.php and tested the 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);
I uploaded it my server, in the root directory. I run it and I received emails with that.
But when I use
$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
}
I get bool true in the var_dump check. But I never received any email from my server.
Any ideas? Have I missed something to configure in WP?
EDIT:
The server won't send any email from yahoo accounts! Why???
$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);