Display friendlier mailer errors when sending paused

[MAILPOET-1699]
This commit is contained in:
Jan Jakeš
2019-02-25 17:33:03 +01:00
committed by M. Shull
parent 9a533a5caf
commit fee5b0d5fa
2 changed files with 64 additions and 25 deletions

View File

@@ -421,44 +421,80 @@ const MailerMixin = {
}
},
getMailerError(state) {
let mailerErrorNotice;
if (state.meta.mta_log.error.operation === 'migration') {
mailerErrorNotice = state.meta.mta_log.error.error_message;
return (
<div>
<p>{ mailerErrorNotice }</p>
<p>{ state.meta.mta_log.error.error_message }</p>
</div>
);
}
const mailerCheckSettingsNotice = ReactStringReplace(
// offer MSS when PHPMail is failing
let mailerErrorCheckSettings;
if (state.meta.mta_method === 'PHPMail') {
mailerErrorCheckSettings = (
<>
<p>{ MailPoet.I18n.t('mailerSendErrorCheckConfiguration') }</p>
<br />
<p>
{
ReactStringReplace(
MailPoet.I18n.t('mailerSendErrorUseSendingService'),
/<b>(.*?)<\/b>/g,
match => <b>{ match }</b>
)
}
</p>
<p>
<a
href="https://www.mailpoet.com/free-plan/?utm_source=plugin&utm_campaign=sending-error"
target="_blank"
rel="noopener noreferrer"
>
{ MailPoet.I18n.t('mailerSendErrorSignUpForSendingService') }
</a>
</p>
<br />
</>
);
} else {
mailerErrorCheckSettings = (
<p>
{
ReactStringReplace(
MailPoet.I18n.t('mailerCheckSettingsNotice'),
/\[link\](.*?)\[\/link\]/g,
match => (
<a href="?page=mailpoet-settings#mta" key="check-sending">{ match }</a>
match => <a href="?page=mailpoet-settings#mta" key="check-sending">{ match }</a>
)
}
</p>
);
if (state.meta.mta_log.error.operation === 'send') {
mailerErrorNotice = MailPoet.I18n.t('mailerSendErrorNotice')
.replace('%$1s', state.meta.mta_method)
.replace('%$2s', state.meta.mta_log.error.error_message);
} else {
mailerErrorNotice = MailPoet.I18n.t('mailerConnectionErrorNotice')
.replace('%$1s', state.meta.mta_log.error.error_message);
}
// append error code if available
let mailerErrorMessage = state.meta.mta_log.error.error_message;
if (state.meta.mta_log.error.error_code) {
mailerErrorNotice += ` ${MailPoet.I18n.t('mailerErrorCode')
.replace('%$1s', state.meta.mta_log.error.error_code)}`;
mailerErrorMessage += mailerErrorMessage ? ', ' : '';
mailerErrorMessage += MailPoet.I18n.t('mailerErrorCode').replace('%$1s', state.meta.mta_log.error.error_code);
}
// eslint-disable-next-line react/no-danger
mailerErrorNotice = <p dangerouslySetInnerHTML={{ __html: mailerErrorNotice }} />;
return (
<div>
{ mailerErrorNotice }
<p>{ mailerCheckSettingsNotice }</p>
<p>
{
state.meta.mta_log.error.operation === 'send'
? MailPoet.I18n.t('mailerSendErrorNotice').replace('%$1s', state.meta.mta_method)
: MailPoet.I18n.t('mailerConnectionErrorNotice')
}
:
{' '}
<i>{ mailerErrorMessage }</i>
</p>
{ mailerErrorCheckSettings }
<p>
<a
href="javascript:;"
className="button"
className="button button-primary"
onClick={MailerMixin.resumeMailerSending}
>
{ MailPoet.I18n.t('mailerResumeSendingButton') }

View File

@@ -278,8 +278,11 @@
'backToPostNotifications': __('Back to Post notifications'),
'noSubscribers': __('No subscribers!'),
'mailerSendErrorNotice': __('Sending is paused because %$1s prevents MailPoet from delivering emails with the following error: %$2s'),
'mailerConnectionErrorNotice': __('Sending is paused because the following connection issue prevents MailPoet from delivering emails: %$1s'),
'mailerSendErrorNotice': __('Sending has been paused due to a technical issue with %$1s'),
'mailerSendErrorCheckConfiguration': __('Please check your sending method configuration, you may need to consult with your hosting company.'),
'mailerSendErrorUseSendingService': __('The easy alternative is to <b>send emails with MailPoet Sending Service</b> instead, like thousand of other users do.'),
'mailerSendErrorSignUpForSendingService': __('Sign up for free in minutes'),
'mailerConnectionErrorNotice': __('Sending is paused because the following connection issue prevents MailPoet from delivering emails'),
'mailerErrorCode': __('Error code: %$1s'),
'mailerCheckSettingsNotice': __('Check your [link]sending method settings[/link].'),
'mailerResumeSendingButton': __('Resume sending'),