Improve the SPF check message [MAILPOET-2511]

This commit is contained in:
wxa
2019-11-28 11:51:22 +03:00
committed by Jack Kitterhing
parent 1a79305766
commit 7be762c462
4 changed files with 10 additions and 16 deletions

View File

@ -1,13 +1,9 @@
import MailPoet from 'mailpoet'; import MailPoet from 'mailpoet';
import _ from 'underscore'; import _ from 'underscore';
const getErrorMessage = (domainName, senderAddress) => `<h3>${MailPoet.I18n.t('spfCheckTitle')}</h3> const getErrorMessage = (senderAddress) => `<h3>${MailPoet.I18n.t('spfCheckTitle')}</h3>
<p>${MailPoet.I18n.t('spfCheckMsgWhy').replace('%s', _.escape(domainName))}</p> <p>${MailPoet.I18n.t('spfCheckMsgWhy').replace('%s', _.escape(senderAddress))}</p>
<p>${MailPoet.I18n.t('spfCheckMsgEdit').replace('%s', '<em>include:spf.sendingservice.net</em>')} <p>${MailPoet.I18n.t('spfCheckMsgEdit').replace('%s', '<em>include:spf.sendingservice.net</em>')}</p>
<br>
<em>v=spf1 include:spf.protection.outlook.com include:sendgrid.net include:spf.sendingservice.net -all</em>
</p>
<p>${MailPoet.I18n.t('spfCheckMsgAllow').replace('%s', _.escape(senderAddress))}</p>
<p><a class="button button-primary" href="https://kb.mailpoet.com/article/151-email-authentication-spf-and-dkim" target="_blank">${MailPoet.I18n.t('spfCheckReadMore')}</a></p>`; <p><a class="button button-primary" href="https://kb.mailpoet.com/article/151-email-authentication-spf-and-dkim" target="_blank">${MailPoet.I18n.t('spfCheckReadMore')}</a></p>`;
const checkSPFRecord = () => MailPoet.Ajax.post({ const checkSPFRecord = () => MailPoet.Ajax.post({
@ -16,9 +12,9 @@ const checkSPFRecord = () => MailPoet.Ajax.post({
action: 'checkSPFRecord', action: 'checkSPFRecord',
data: {}, data: {},
}).fail((response) => { }).fail((response) => {
if (response.meta.domain_name && response.meta.sender_address) { if (response.meta.sender_address) {
MailPoet.Notice.error( MailPoet.Notice.error(
getErrorMessage(response.meta.domain_name, response.meta.sender_address), getErrorMessage(response.meta.sender_address),
{ static: true, scroll: true, id: 'spf_check_error' } { static: true, scroll: true, id: 'spf_check_error' }
); );
} }

View File

@ -50,7 +50,7 @@ class Services extends APIEndpoint {
if (!$result) { if (!$result) {
return $this->errorResponse( return $this->errorResponse(
[APIError::BAD_REQUEST => WPFunctions::get()->__('SPF check has failed.', 'mailpoet')], [APIError::BAD_REQUEST => WPFunctions::get()->__('SPF check has failed.', 'mailpoet')],
['sender_address' => $sender_address, 'domain_name' => $domain_name] ['sender_address' => $sender_address]
); );
} }

View File

@ -37,7 +37,6 @@ class ServicesTest extends \MailPoetTest {
$response = $services_endpoint->checkSPFRecord([]); $response = $services_endpoint->checkSPFRecord([]);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->meta['sender_address'])->equals($email); expect($response->meta['sender_address'])->equals($email);
expect($response->meta['domain_name'])->equals('example.com');
} }
function testItRespondsWithSuccessIfSPFCheckPasses() { function testItRespondsWithSuccessIfSPFCheckPasses() {

View File

@ -84,11 +84,10 @@ jQuery('.toplevel_page_mailpoet-newsletters.menu-top-last')
'senderEmailAddressWarning3': _x('Read more.'), 'senderEmailAddressWarning3': _x('Read more.'),
'mailerSendingResumedNotice': __('Sending has been resumed.'), 'mailerSendingResumedNotice': __('Sending has been resumed.'),
'spfCheckTitle': _x('Oops! You might not receive your own emails.', 'DNS SPF Record check'), 'spfCheckTitle': _x('Improve your deliverability!', 'DNS SPF Record check'),
'spfCheckMsgWhy': _x("Why? You have an SPF entry for %s, but it's incomplete.", 'DNS SPF Record check'), 'spfCheckMsgWhy': _x("Your email is set to be sent from %s and we noticed that you have an SPF record for this domain. It means some subscribers may not receive your emails.", 'DNS SPF Record check'),
'spfCheckMsgEdit': _x('If you send with MailPoet, edit the SPF record in your DNS and add %s to it, so it looks like this:', 'DNS SPF Record check'), 'spfCheckMsgEdit': _x("Since you're sending with the MailPoet Sending Service, you need to add %s to the existing SPF entry in your DNS records. This will allow MailPoet to send on your behalf for optimal deliverability.", 'DNS SPF Record check'),
'spfCheckMsgAllow': _x('This will allow MailPoet to send emails from %s addresses.', 'DNS SPF Record check'), 'spfCheckReadMore': _x('Read the Guide', 'DNS SPF Record check'),
'spfCheckReadMore': _x('Read more about SPF', 'DNS SPF Record check'),
}) %> }) %>
<% block translations %><% endblock %> <% block translations %><% endblock %>