Show error notice when email is sent from unauthorized email
[MAILPOET-1787]
This commit is contained in:
@ -22,8 +22,9 @@ class MailPoetMapper {
|
||||
);
|
||||
}
|
||||
|
||||
function getErrorForResult(array $result, $subscribers) {
|
||||
function getErrorForResult(array $result, $subscribers, $sender = null) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
$operation = MailerError::OPERATION_SEND;
|
||||
$retry_interval = null;
|
||||
$subscribers_errors = [];
|
||||
$result_code = !empty($result['code']) ? $result['code'] : null;
|
||||
@ -51,18 +52,35 @@ class MailPoetMapper {
|
||||
$retry_interval = self::TEMPORARY_UNAVAILABLE_RETRY_INTERVAL;
|
||||
break;
|
||||
case API::RESPONSE_CODE_CAN_NOT_SEND:
|
||||
$message = Helpers::replaceLinkTags(
|
||||
__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
|
||||
'https://www.mailpoet.com/support/',
|
||||
array('target' => '_blank')
|
||||
);
|
||||
if ($result['message'] === MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED) {
|
||||
$operation = MailerError::OPERATION_AUTHORIZATION;
|
||||
$message = sprintf(__('<p>The MailPoet Sending Service did not send your latest email because the address <i>%s</i> is not yet authorized.</p>', 'mailpoet'), $sender ? $sender['from_email'] : __('Unknown address'));
|
||||
$message .= '<p>';
|
||||
$message .= Helpers::replaceLinkTags(
|
||||
__('[link]Authorize your email in your account now.[/link]', 'mailpoet'),
|
||||
'https://account.mailpoet.com/account/authorization',
|
||||
array(
|
||||
'class' => 'button button-primary',
|
||||
'target' => '_blank',
|
||||
)
|
||||
);
|
||||
$message .= ' <button class="button js-button-resume-sending">' . __('Resume sending', 'mailpoet') . '</button>';
|
||||
$message .= '</p>';
|
||||
$message .= "<script>jQuery('.js-button-resume-sending').on('click', function() { MailPoet.Ajax.post({ api_version: window.mailpoet_api_version, endpoint: 'mailer', action: 'resumeSending' }).done(function() { jQuery('.js-error-unauthorized-email').slideUp(); MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice')); if (window.mailpoet_listing) { window.mailpoet_listing.forceUpdate(); }}).fail(function(response) { if (response.errors.length > 0) { MailPoet.Notice.error(response.errors.map(function(error) { return error.message }), { scroll: true }); }}); })</script>";
|
||||
} else {
|
||||
$message = Helpers::replaceLinkTags(
|
||||
__('You currently are not permitted to send any emails with MailPoet Sending Service, which may have happened due to poor deliverability. Please [link]contact our support team[/link] to resolve the issue.', 'mailpoet'),
|
||||
'https://www.mailpoet.com/support/',
|
||||
array('target' => '_blank')
|
||||
);
|
||||
}
|
||||
break;
|
||||
case API::RESPONSE_CODE_KEY_INVALID:
|
||||
case API::RESPONSE_CODE_PAYLOAD_TOO_BIG:
|
||||
default:
|
||||
$message = $result['message'];
|
||||
}
|
||||
return new MailerError(MailerError::OPERATION_SEND, $level, $message, $retry_interval, $subscribers_errors);
|
||||
return new MailerError($operation, $level, $message, $retry_interval, $subscribers_errors);
|
||||
}
|
||||
|
||||
private function getSubscribersErrors($result_parsed, $subscribers) {
|
||||
|
Reference in New Issue
Block a user