AmazonSESMapper.php
3 years ago
BlacklistErrorMapperTrait.php
3 years ago
ConnectionErrorMapperTrait.php
3 years ago
MailPoetMapper.php
1 year ago
PHPMailMapper.php
4 years ago
PHPMailerMapper.php
3 years ago
SMTPMapper.php
4 years ago
SendGridMapper.php
3 years ago
index.php
3 years ago
PHPMailerMapper.php
33 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Mailer\Methods\ErrorMappers; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Mailer\MailerError; |
| 9 | use MailPoet\Mailer\SubscriberError; |
| 10 | |
| 11 | abstract class PHPMailerMapper { |
| 12 | use ConnectionErrorMapperTrait; |
| 13 | |
| 14 | public function getErrorFromException(\Exception $e, $subscriber) { |
| 15 | $level = MailerError::LEVEL_HARD; |
| 16 | if (strpos($e->getMessage(), 'Invalid address') === 0) { |
| 17 | $level = MailerError::LEVEL_SOFT; |
| 18 | } |
| 19 | |
| 20 | $subscriberErrors = [new SubscriberError($subscriber, null)]; |
| 21 | return new MailerError(MailerError::OPERATION_SEND, $level, $e->getMessage(), null, $subscriberErrors); |
| 22 | } |
| 23 | |
| 24 | public function getErrorForSubscriber($subscriber) { |
| 25 | // translators: %s is the name of the method. |
| 26 | $message = sprintf(__('%s has returned an unknown error.', 'mailpoet'), $this->getMethodName()); |
| 27 | $subscriberErrors = [new SubscriberError($subscriber, null)]; |
| 28 | return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $message, null, $subscriberErrors); |
| 29 | } |
| 30 | |
| 31 | abstract protected function getMethodName(): string; |
| 32 | } |
| 33 |