Here are some small block of codes that you can include in your functions.php
if your calls to wp_mail
fail.
Problems could happen in other part of the sending process (for example in the SMTP server), but you can try these:
/* specify the From header in email */
add_action( 'phpmailer_init', 'fix_return_path' );
function fix_return_path( $phpmailer ) {
$phpmailer->Sender = $phpmailer->From;
}
/* force the use of from header */
add_filter( 'wp_mail_from', 'force_from' );
function force_from( $email ) {
return "noreply@yourdomain.com";
}
/* add the name of the sender */
add_filter( 'wp_mail_from_name', 'force_from_name' );
function force_from_name( $name ) {
return bloginfo('name');
}
All those lines of code try to better compose your email when WordPress send messages using wp_mail
. A mail composed properly can pass antispam filters better.
If these lines don’t solve the problem try to send an email from a php file with the mail function.
If it doesn’t send emails the problem belongs to the server, you can also try an external SMTP server (there are also WordPress plugins that let wp_mail
use an external SMTP server).