Compare commits
5 Commits
update-plu
...
3.32.1
Author | SHA1 | Date | |
---|---|---|---|
ecc1f8a152 | |||
595145e50f | |||
0b6490e817 | |||
9018ab8c5f | |||
84fabcfbd5 |
@ -8,6 +8,8 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class AmazonSES {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $aws_access_key;
|
||||
public $aws_secret_key;
|
||||
public $aws_region;
|
||||
@ -67,6 +69,10 @@ class AmazonSES {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
try {
|
||||
$result = $this->wp->wpRemotePost(
|
||||
$this->url,
|
||||
|
29
lib/Mailer/Methods/BlacklistTrait.php
Normal file
29
lib/Mailer/Methods/BlacklistTrait.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace MailPoet\Mailer\Methods;
|
||||
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
|
||||
trait BlacklistTrait {
|
||||
/** @var Blacklist */
|
||||
private $blacklist;
|
||||
|
||||
function isBlacklisted($subscriber) {
|
||||
$email = $this->getSubscriberEmailForBlacklistCheck($subscriber);
|
||||
return $this->getBlacklist()->isBlacklisted($email);
|
||||
}
|
||||
|
||||
private function getSubscriberEmailForBlacklistCheck($subscriber_string) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber_string, $subscriber_data);
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
return $subscriber_string;
|
||||
}
|
||||
return $subscriber_data['email'];
|
||||
}
|
||||
|
||||
private function getBlacklist() {
|
||||
if (!$this->blacklist instanceof Blacklist) {
|
||||
$this->blacklist = new Blacklist();
|
||||
}
|
||||
return $this->blacklist;
|
||||
}
|
||||
}
|
@ -7,8 +7,11 @@ use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class AmazonSESMapper {
|
||||
use BlacklistErrorMapperTrait;
|
||||
use ConnectionErrorMapperTrait;
|
||||
|
||||
const METHOD = Mailer::METHOD_AMAZONSES;
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if ($e instanceof \Swift_RfcComplianceException) {
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace MailPoet\Mailer\Methods\ErrorMappers;
|
||||
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
trait BlacklistErrorMapperTrait {
|
||||
function getBlacklistError($subscriber) {
|
||||
$message = sprintf(WPFunctions::get()->__('%s has returned an unknown error.', 'mailpoet'), self::METHOD);
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_SOFT, $message, null, $subscriber_errors);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
namespace MailPoet\Mailer\Methods\ErrorMappers;
|
||||
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\Services\Bridge\API;
|
||||
use InvalidArgumentException;
|
||||
@ -14,8 +15,11 @@ if (!defined('ABSPATH')) exit;
|
||||
|
||||
|
||||
class MailPoetMapper {
|
||||
use BlacklistErrorMapperTrait;
|
||||
use ConnectionErrorMapperTrait;
|
||||
|
||||
const METHOD = Mailer::METHOD_MAILPOET;
|
||||
|
||||
const TEMPORARY_UNAVAILABLE_RETRY_INTERVAL = 300; // seconds
|
||||
|
||||
function getInvalidApiKeyError() {
|
||||
|
@ -7,8 +7,11 @@ use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class PHPMailMapper {
|
||||
use BlacklistErrorMapperTrait;
|
||||
use ConnectionErrorMapperTrait;
|
||||
|
||||
const METHOD = Mailer::METHOD_PHPMAIL;
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if (strpos($e->getMessage(), 'Invalid address') === 0) {
|
||||
|
@ -7,8 +7,11 @@ use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class SMTPMapper {
|
||||
use BlacklistErrorMapperTrait;
|
||||
use ConnectionErrorMapperTrait;
|
||||
|
||||
const METHOD = Mailer::METHOD_SMTP;
|
||||
|
||||
/**
|
||||
* @see https://swiftmailer.symfony.com/docs/sending.html
|
||||
* @return MailerError
|
||||
|
@ -7,8 +7,11 @@ use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class SendGridMapper {
|
||||
use BlacklistErrorMapperTrait;
|
||||
use ConnectionErrorMapperTrait;
|
||||
|
||||
const METHOD = Mailer::METHOD_SENDGRID;
|
||||
|
||||
function getErrorFromResponse($response, $subscriber) {
|
||||
$response = (!empty($response['errors'][0])) ?
|
||||
$response['errors'][0] :
|
||||
|
@ -12,6 +12,8 @@ use MailPoet\Services\Bridge\API;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class MailPoet {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $api;
|
||||
public $sender;
|
||||
public $reply_to;
|
||||
@ -37,6 +39,14 @@ class MailPoet {
|
||||
return Mailer::formatMailerErrorResult($this->error_mapper->getInvalidApiKeyError());
|
||||
}
|
||||
|
||||
$subscribers_for_blacklist_check = is_array($subscriber) ? $subscriber : [$subscriber];
|
||||
foreach ($subscribers_for_blacklist_check as $sub) {
|
||||
if ($this->isBlacklisted($sub)) {
|
||||
$error = $this->error_mapper->getBlacklistError($sub);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
}
|
||||
|
||||
$message_body = $this->getBody($newsletter, $subscriber, $extra_params);
|
||||
$result = $this->api->sendMessages($message_body);
|
||||
|
||||
|
@ -10,6 +10,8 @@ if (!defined('ABSPATH')) exit;
|
||||
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
||||
|
||||
class PHPMail {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $sender;
|
||||
public $reply_to;
|
||||
public $return_path;
|
||||
@ -29,6 +31,10 @@ class PHPMail {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
try {
|
||||
$mailer = $this->configureMailerWithMessage($newsletter, $subscriber, $extra_params);
|
||||
$result = $mailer->send();
|
||||
|
@ -8,6 +8,8 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SMTP {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $host;
|
||||
public $port;
|
||||
public $authentication;
|
||||
@ -48,6 +50,10 @@ class SMTP {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
try {
|
||||
$message = $this->createMessage($newsletter, $subscriber, $extra_params);
|
||||
$result = $this->mailer->send($message);
|
||||
|
@ -9,6 +9,8 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SendGrid {
|
||||
use BlacklistTrait;
|
||||
|
||||
public $url = 'https://api.sendgrid.com/api/mail.send.json';
|
||||
public $api_key;
|
||||
public $sender;
|
||||
@ -28,6 +30,10 @@ class SendGrid {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
}
|
||||
$result = $this->wp->wpRemotePost(
|
||||
$this->url,
|
||||
$this->request($newsletter, $subscriber, $extra_params)
|
||||
|
25
lib/Subscription/Blacklist.php
Normal file
25
lib/Subscription/Blacklist.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace MailPoet\Subscription;
|
||||
|
||||
class Blacklist {
|
||||
const SALT = 'mailpoet';
|
||||
|
||||
private $blacklist = [
|
||||
'e60c6e0e73997c92d4ceac78a6b6cbbe6249244c4106a3c31de421fc50370ecd' => 1,
|
||||
];
|
||||
|
||||
public function __construct(array $blacklist = null) {
|
||||
if ($blacklist) {
|
||||
$this->blacklist = array_fill_keys(array_map([$this, 'hash'], $blacklist), 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function isBlacklisted($email) {
|
||||
$hashed_email = $this->hash($email);
|
||||
return isset($this->blacklist[$hashed_email]);
|
||||
}
|
||||
|
||||
private function hash($email) {
|
||||
return hash('sha256', $email . self::SALT);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ if (!defined('ABSPATH')) exit;
|
||||
|
||||
/*
|
||||
* Plugin Name: MailPoet 3 (New)
|
||||
* Version: 3.31.1
|
||||
* Version: 3.32.1
|
||||
* Plugin URI: http://www.mailpoet.com
|
||||
* Description: Create and send newsletters, post notifications and welcome emails from your WordPress.
|
||||
* Author: MailPoet
|
||||
@ -18,7 +18,7 @@ if (!defined('ABSPATH')) exit;
|
||||
*/
|
||||
|
||||
$mailpoet_plugin = array(
|
||||
'version' => '3.31.1',
|
||||
'version' => '3.32.1',
|
||||
'filename' => __FILE__,
|
||||
'path' => dirname(__FILE__),
|
||||
'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',
|
||||
|
@ -3,7 +3,7 @@ Contributors: mailpoet, wysija
|
||||
Tags: email marketing, newsletter, newsletter subscribers, email, welcome email, post notification, WooCommerce emails, newsletter builder
|
||||
Requires at least: 4.7
|
||||
Tested up to: 5.2
|
||||
Stable tag: 3.31.1
|
||||
Stable tag: 3.32.1
|
||||
License: GPLv3
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
@ -147,6 +147,12 @@ Stop by our [support site](https://www.mailpoet.com/support).
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 3.32.1 - 2019-07-11 =
|
||||
* Improved: minor changes and fixes.
|
||||
|
||||
= 3.32.0 - 2019-07-09 =
|
||||
* Improved: messages for undo/redo actions.
|
||||
|
||||
= 3.31.1 - 2019-07-03 =
|
||||
* Improved: minor changes and fixes.
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Mailer\Methods;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Methods\AmazonSES;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\AmazonSESMapper;
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
|
||||
class AmazonSESTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@ -233,6 +235,23 @@ class AmazonSESTest extends \MailPoetTest {
|
||||
expect($result['error']->getMessage())->contains('does not comply with RFC 2822');
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSending() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
['blacklist' => $blacklist, 'error_mapper' => new AmazonSESMapper()],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
$blacklisted_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('AmazonSES has returned an unknown error.');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
if (getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') return;
|
||||
$result = $this->mailer->send(
|
||||
|
@ -9,6 +9,7 @@ use MailPoet\Mailer\Methods\ErrorMappers\MailPoetMapper;
|
||||
use MailPoet\Mailer\Methods\MailPoet;
|
||||
use MailPoet\Services\AuthorizedEmailsController;
|
||||
use MailPoet\Services\Bridge\API;
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
|
||||
class MailPoetAPITest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@ -255,4 +256,56 @@ class MailPoetAPITest extends \MailPoetTest {
|
||||
);
|
||||
$mailer->send([$this->newsletter], [$this->subscriber]);
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSendingToASingleSubscriber() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
[
|
||||
'blacklist' => $blacklist,
|
||||
'error_mapper' => new MailPoetMapper(),
|
||||
'services_checker' => Stub::make(
|
||||
new ServicesChecker(),
|
||||
['isMailPoetAPIKeyValid' => true],
|
||||
$this
|
||||
),
|
||||
],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
$blacklisted_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('unknown error');
|
||||
expect($result['error']->getMessage())->contains('MailPoet has returned an unknown error.');
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSendingToMultipleSubscribers() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
[
|
||||
'blacklist' => $blacklist,
|
||||
'error_mapper' => new MailPoetMapper(),
|
||||
'services_checker' => Stub::make(
|
||||
new ServicesChecker(),
|
||||
['isMailPoetAPIKeyValid' => true],
|
||||
$this
|
||||
),
|
||||
],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
['good@example.com', $blacklisted_subscriber, 'good2@example.com']
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('unknown error');
|
||||
expect($result['error']->getMessage())->contains('MailPoet has returned an unknown error.');
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Mailer\Methods;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\PHPMailMapper;
|
||||
use MailPoet\Mailer\Methods\PHPMail;
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
|
||||
class PHPMailTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@ -112,6 +115,23 @@ class PHPMailTest extends \MailPoetTest {
|
||||
]);
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSending() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
['blacklist' => $blacklist, 'error_mapper' => new PHPMailMapper()],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
$blacklisted_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('PHPMail has returned an unknown error.');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
if (getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') return;
|
||||
$result = $this->mailer->send(
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Mailer\Methods;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SMTPMapper;
|
||||
use MailPoet\Mailer\Methods\SMTP;
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class SMTPTest extends \MailPoetTest {
|
||||
@ -171,6 +174,23 @@ class SMTPTest extends \MailPoetTest {
|
||||
expect($mailer->getTransport()->getTimeout())->equals(20);
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSending() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
['blacklist' => $blacklist, 'error_mapper' => new SMTPMapper()],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
$blacklisted_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('SMTP has returned an unknown error.');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
if (getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') return;
|
||||
$result = $this->mailer->send(
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Mailer\Methods;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\Methods\ErrorMappers\SendGridMapper;
|
||||
use MailPoet\Mailer\Methods\SendGrid;
|
||||
use MailPoet\Subscription\Blacklist;
|
||||
|
||||
class SendGridTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@ -82,6 +85,23 @@ class SendGridTest extends \MailPoetTest {
|
||||
expect($result['response'])->false();
|
||||
}
|
||||
|
||||
function testItChecksBlacklistBeforeSending() {
|
||||
$blacklisted_subscriber = 'blacklist_test@example.com';
|
||||
$blacklist = Stub::make(new Blacklist(), ['isBlacklisted' => true], $this);
|
||||
$mailer = Stub::make(
|
||||
$this->mailer,
|
||||
['blacklist' => $blacklist, 'error_mapper' => new SendGridMapper()],
|
||||
$this
|
||||
);
|
||||
$result = $mailer->send(
|
||||
$this->newsletter,
|
||||
$blacklisted_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error'])->isInstanceOf(MailerError::class);
|
||||
expect($result['error']->getMessage())->contains('SendGrid has returned an unknown error.');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
if (getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') return;
|
||||
$result = $this->mailer->send(
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
__halt_compiler();
|
||||
|
||||
namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
|
||||
|
||||
use MailPoet\Mailer\MailerError;
|
||||
@ -20,6 +20,15 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
|
||||
$this->subscribers = ['a@example.com', 'c d <b@example.com>'];
|
||||
}
|
||||
|
||||
function testCreateBlacklistError() {
|
||||
$error = $this->mapper->getBlacklistError($this->subscribers[1]);
|
||||
expect($error)->isInstanceOf(MailerError::class);
|
||||
expect($error->getOperation())->equals(MailerError::OPERATION_SEND);
|
||||
expect($error->getLevel())->equals(MailerError::LEVEL_SOFT);
|
||||
expect($error->getMessage())->contains('unknown error');
|
||||
expect($error->getMessage())->contains('MailPoet');
|
||||
}
|
||||
|
||||
function testCreateConnectionError() {
|
||||
$error = $this->mapper->getConnectionError('connection error');
|
||||
expect($error)->isInstanceOf(MailerError::class);
|
||||
@ -53,14 +62,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
|
||||
expect($error)->isInstanceOf(MailerError::class);
|
||||
expect($error->getOperation())->equals(MailerError::OPERATION_SEND);
|
||||
expect($error->getLevel())->equals(MailerError::LEVEL_HARD);
|
||||
expect($error->getMessage())->equals(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',
|
||||
'rel' => 'noopener noreferrer',
|
||||
)
|
||||
));
|
||||
expect($error->getMessage())->contains('The MailPoet Sending Service has stopped sending your emails for one of the following reasons');
|
||||
}
|
||||
|
||||
function testGetErrorUnauthorizedEmail() {
|
||||
@ -107,7 +109,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
|
||||
$api_result = [
|
||||
'code' => API::RESPONSE_CODE_PAYLOAD_ERROR,
|
||||
'status' => API::SENDING_STATUS_SEND_ERROR,
|
||||
'message' => '[{"index":0,"errors":{"subject":"subject is missing"}},{"index":1,"errors":{"subject":"subject is missing"}}]'
|
||||
'message' => '[{"index":0,"errors":{"subject":"subject is missing"}},{"index":1,"errors":{"subject":"subject is missing"}}]',
|
||||
];
|
||||
$error = $this->mapper->getErrorForResult($api_result, $this->subscribers);
|
||||
expect($error)->isInstanceOf(MailerError::class);
|
||||
@ -125,7 +127,7 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
|
||||
$api_result = [
|
||||
'code' => API::RESPONSE_CODE_PAYLOAD_ERROR,
|
||||
'status' => API::SENDING_STATUS_SEND_ERROR,
|
||||
'message' => '[{"errors":{"subject":"subject is missing"}},{"errors":{"subject":"subject is missing"}}]'
|
||||
'message' => '[{"errors":{"subject":"subject is missing"}},{"errors":{"subject":"subject is missing"}}]',
|
||||
];
|
||||
$error = $this->mapper->getErrorForResult($api_result, $this->subscribers);
|
||||
expect($error)->isInstanceOf(MailerError::class);
|
||||
|
14
tests/unit/Subscription/BlacklistTest.php
Normal file
14
tests/unit/Subscription/BlacklistTest.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace MailPoet\Subscription;
|
||||
|
||||
class BlacklistTest extends \MailPoetUnitTest {
|
||||
function testItChecksBlacklistedEmails() {
|
||||
$email = 'test@example.com';
|
||||
$blacklist = new Blacklist();
|
||||
$result = $blacklist->isBlacklisted($email);
|
||||
expect($result)->equals(false);
|
||||
$blacklist = new Blacklist([$email]);
|
||||
$result = $blacklist->isBlacklisted($email);
|
||||
expect($result)->equals(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user