Show error notice when email is sent from unauthorized email
[MAILPOET-1787]
This commit is contained in:
@ -73,6 +73,7 @@ class Menu {
|
||||
$this->subscribers_over_limit = $subscribers_feature->check();
|
||||
$this->checkMailPoetAPIKey();
|
||||
$this->checkPremiumKey();
|
||||
$this->checkFromEmailAuthorization();
|
||||
|
||||
add_action(
|
||||
'admin_menu',
|
||||
@ -836,6 +837,13 @@ class Menu {
|
||||
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices);
|
||||
}
|
||||
|
||||
function checkFromEmailAuthorization(ServicesChecker $checker = null) {
|
||||
if (self::isOnMailPoetAdminPage()) {
|
||||
$checker = $checker ?: new ServicesChecker();
|
||||
$checker->isFromEmailAuthorized(true);
|
||||
}
|
||||
}
|
||||
|
||||
function getLimitPerPage($model = null) {
|
||||
if ($model === null) {
|
||||
return Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\Config;
|
||||
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
@ -115,4 +116,17 @@ class ServicesChecker {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isFromEmailAuthorized($display_error_notice = true) {
|
||||
$mta_log_error = $this->settings->get('mta_log.error', []);
|
||||
|
||||
if ($mta_log_error && $mta_log_error['operation'] === MailerError::OPERATION_AUTHORIZATION) {
|
||||
if ($display_error_notice) {
|
||||
WPNotice::displayError($mta_log_error['error_message'], 'js-error-unauthorized-email', '', false, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user