Add SPF record notice [MAILPOET-2295]

This commit is contained in:
wxa
2019-09-02 09:56:52 +03:00
committed by Jack Kitterhing
parent f67e356202
commit a97376b443
6 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import MailPoet from 'mailpoet';
import _ from 'underscore';
const getErrorMessage = (domainName, senderAddress) => `<h3>${MailPoet.I18n.t('spfCheckTitle')}</h3>
<p>${MailPoet.I18n.t('spfCheckMsgWhy').replace('%s', _.escape(domainName))}</p>
<p>${MailPoet.I18n.t('spfCheckMsgEdit').replace('%s', '<em>include:spf.sendingservice.net</em>')}
<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>`;
const checkSPFRecord = () => MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'services',
action: 'checkSPFRecord',
data: {},
}).fail((response) => {
if (response.meta.domain_name && response.meta.sender_address) {
MailPoet.Notice.error(
getErrorMessage(response.meta.domain_name, response.meta.sender_address),
{ static: true, scroll: true, id: 'spf_check_error' }
);
}
});
export default checkSPFRecord;

View File

@@ -7,6 +7,7 @@ import Marionette from 'backbone.marionette';
import SuperModel from 'backbone.supermodel';
import _ from 'underscore';
import jQuery from 'jquery';
import checkSPFRecord from 'common/check_spf_record.jsx';
var Module = {};
var SidebarView;
@@ -328,6 +329,9 @@ Module.SidebarPreviewView = Marionette.View.extend({
'MailPoet Free version': window.mailpoet_version,
'Domain name': data.subscriber.substring(data.subscriber.indexOf('@') + 1),
});
if (App.getConfig().get('validation.validateSPFRecord')) {
checkSPFRecord();
}
showSuccessDeliveryPoll = MailPoet.Poll.successDelivery.canShow('preview');
if (showSuccessDeliveryPoll) {
MailPoet.Poll.successDelivery.showModal('preview', 'IHedf1');