5

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()?

Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51
lenrooney
  • 73
  • 1
  • 10
  • 1
    Real answer here: https://wordpress.stackexchange.com/a/45291/25035 – vsync Apr 21 '18 at 16:20
  • 1
    Please see this solution https://stackoverflow.com/questions/20703958/wp-mail-wordpress-mail-function-not-sending-to-gmail-or-live-co-uk-accounts?rq=1 – Gufran Hasan Mar 07 '19 at 15:48

0 Answers0