wp_mail only sends emails to gmail and i receive emails only on gmail inbox but in dedicated servers couldnt send recieve anything even as spam followed data works well only to gmail

        add_filter( 'wp_mail_content_type', array( $this, 'set_html_mail_content_type' ) );
        $to = myacc@gmail.com;

        $subject = 'test';
        wp_mail( $to, $subject, 'body');

        remove_filter( 'wp_mail_content_type', array( $this, 'set_html_mail_content_type' ) );

  • How have you configured WordPress to send emails? Are you using the default, which is a local SMTP server running on your WordPress server I think? How is that set up to route onward email? Is the from address you're using on a domain that's set up for SPF i.e. it is likely to be flagged as spam if it's sent from the wrong servers?
    – Rup
    Jul 17, 2020 at 11:36

1 Answer 1


Welcome to WPD stack exchange.

as I am see its look like sometimes we have forgot to add some basic need and function not working properly.

Please try with header parameter:

$headers[] = 'Content-type: text/plain; charset=utf-8';  
$headers[] = 'From:' . "testing@gmail.com";

Also, you can use Easy WP SMTP and enable debugging and/or set that up to use SMTP. If something like GMail works then you'll know it is a server setting and not this code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.