Add blacklist to Mailer [MAILPOET-2176]
This commit is contained in:
@ -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] :
|
||||
|
Reference in New Issue
Block a user