I'm trying to solve a problem with email being sent from a WordPress site, hosted on GoDaddy with its MX record set to a Dreamhost.com mail server.
Email addressed to the site's domain (me@mysitesdomain.com)
will not go through, yet email to any @gmail.com
address will go through. I'm testing this with the following script ...
<?php
$mailResult = false;
$from = "info@mysitesdomain.com";
$to = "me@mysitesdomain.com";
$subject = "PHP Mail Test script";
$message = "This is a test to check the wp_mail functionality.";
$headers = "From:" . $from;
$mailResult = wp_mail( $to, $subject, $message, $headers );
echo "mail result: ".$mailResult;
?>
For both the me@mysitesdomain.com
and the me@gmail.com
address, the script's result is 1 (true).
As a further test, I use a similar very simple script outside of Wordpress that uses PHP mail()...
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "info@mysitesdomain.com";
$to = "me@mysitesdomain.com";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality.;
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>
That script successfully sends to both addresses. So, PHP mail()
works but wp_mail()
only works for @gmail.com
addresses. What's going on within the wp_mail class that's different PHP php mail()
?