• Hey guys,

    Have a big issue that needs fixing in terms of sending emails from my domains. I have tried several tests and found that only one of my three domains can send emails using the wp_mail function. The domain that can send it isnt my main domain and is in fact one of my sub domains. The thing is in the past the wp_mail function worked on all my domains and future domains I created. I got to this stage by using a newsletter plugin to send emails to our users and subscribers on our page. In order to get the newsletters to work I created a DKIM codes etc and put the appropriate codes in the zone editor. I got it to work for one domain but not for the other so with the help of our hosting company they configured our server so that all the domains could use one code to send. After that I discovered the problem of wp_mail not working with some of my plugins and some third party plugins including smtp mail plugin. Only one of the three domains worked and the one that did work was a subdomain. My hosting provider thinks its a wordpress issue but even using a script that removes themes and disables plugins it still only works on that sub-domain. Has anyone ever had an issue like this? Does anyone know of a solution?

    <?php
    
    $to = "[email protected]";
    
    // No need to make changes below this line
    
    // Email subject and body text
    $subject = 'wp_mail function test';
    $message = 'This is a test of the wp_mail function: wp_mail is working';
    $headers = '';
    
    // Load WP components, no themes
    define('WP_USE_THEMES', false);
    require('wp-load.php');
    
    // send test message using wp_mail function
    $sent_message = wp_mail( $to, $subject, $message, $headers );
    
    //display message based on the result.
    if ( $sent_message ) {
        // the message was sent...
        echo 'The test message was sent. Check your email inbox.';
    } else {
        // the message was not sent...
        echo 'The message was not sent!';
    }

    This script only works on one subdomain and lets me send it to any email address.
    Even after creating a fresh install of wordpress on one of our subdomains it still doesnt work.

The topic ‘WordPress wp_mail function only working on some domains’ is closed to new replies.