Add soft level errors distinction for SendGrid service

[MAILPOET-1154]
This commit is contained in:
Rostislav Wolny
2018-09-11 13:20:04 +02:00
parent 6df1db933e
commit 6437f4a1b3
2 changed files with 42 additions and 1 deletions

View File

@ -13,10 +13,15 @@ class SendGridMapper {
$response['errors'][0] :
sprintf(__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_SENDGRID);
$level = MailerError::LEVEL_HARD;
if(strpos($response, 'Invalid email address') === 0) {
$level = MailerError::LEVEL_SOFT;
}
$subscriber_errors = [];
if(empty($extra_params['test_email'])) {
$subscriber_errors[] = new SubscriberError($subscriber, null);
}
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $response, null, $subscriber_errors);
return new MailerError(MailerError::OPERATION_SEND, $level, $response, null, $subscriber_errors);
}
}