Reputation: 3832
I have a Wordpress site hosted at Cloudways. I have installed their Elastic Email SMTP add on. In theory I only need to activate the add on, and then the server will take care of STMP relay and authentication. Which means I don't need a SMTP plugin for Wordpress.
I have added a SPF value of v=spf1 a mx include:_spf.elasticemail.com ~all
and a DKIM value of k=rsa;t=s;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbmGbQMzYeMvxwtNQoXN0waGYaciuKx8mtMh5czguT4EZlJXuCt6V+l56mmt3t68FEX5JJ0q4ijG71BGoFRkl87uJi7LrQt1ZZmZCvrEII0YO4mp8sDLXC8g1aUAoi8TJgxq2MJqCaMyj5kAm3Fdy2tzftPCV/lbdiJqmBnWKjtwIDAQAB
to my DNS settings, acording to Elastic emails own guidelines.
If send some test email trough a small PHP scrip on my server:
$to = "[email protected]";
$subject = "Testing";
$txt = "Hello world!";
mail($to,$subject,$txt,'From: [email protected] ','-f [email protected] ');
I get excellent score at www.mail-tester.com, and the email also arrive without problems at two different inboxes of mine.
But when I try to send email from wordpress, trough the plugin "check email" I get crappy score at www.mail-tester.com... It's says I'm not fully authenticated and I get -3 minus score for this line in particular: We didn't find a mail server (MX Record) behind your domain name xxxxxx.cloudwaysapps.com.
How comes I get so bad score when sending test email trough Wordpress compared to a simple php test script, and what should I do to get reliable score on outgoing mail from Wordpress?
Upvotes: 1
Views: 1123
Reputation: 601
You can also code this very quickly in the functions.php theme file. For example:
function my_phpmailer_example( $phpmailer ) {
$phpmailer->ReturnPath='[email protected]';
$phpmailer->Sender='[email protected]';
$phpmailer->SetFrom('[email protected]', 'My Name', FALSE);
}
add_action( 'phpmailer_init', 'my_phpmailer_example' );
In my experience, actively setting all three of these entries explicitly will really help with dkim and spf validation issues.
Upvotes: 0
Reputation: 166
For WordPress, the actual problem is what you have identified in your second comment.
There is another workaround if you use “WP Mail SMTP" plugin on your WordPress site. It overrides the default WordPress email behavior with your customized settings.
Cloudways has written a complete guide on setting up SMTP on WordPress. In their example, they have used Gmail SMTP, but the steps are same for Elastic Email.
Upvotes: 2
Reputation: 3832
The problem is that Wordpress has a default behavior of setting Return-Path to the server address, in my case: xxxxxx.cloudwaysapps.com
instead of [email protected]
. The solution and what also makes the email much more likely to reach an inbox is to modify the default behavior of Wordpress with this tiny plugin. It sets the Return-Path header of outgoing emails to equal the from email address.
Upvotes: 1