Skip to content

Commit

Permalink
[TASK] Change log message level for rejected email addresses
Browse files Browse the repository at this point in the history
Because CleverReach sends a generic 403 error for spam email addresses
and this response can not be distinguished from other reasons email
address are rejected, we separate the logging of a 403 response and
lower the log level.
  • Loading branch information
helmutstrasser committed Apr 15, 2024
1 parent 2497744 commit 45326d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Classes/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ public function sendSubscribeMail(string $email, ?int $formId = null, ?int $grou
]
);
} catch (GuzzleException $ex) {
$this->logger->alert('cannot send subscribe email: ' . $ex->getMessage(), [$ex]);
// Because CleverReach sends a generic 403 error if the email address is deemed to be spam (which happens
// frequently), and there is no way to distinguish this from any other reason an email address is forbidden,
// we log this as a warning instead of an error.
if ($ex instanceof BadResponseException && (int)$ex->getCode() === 403) {
$this->logger->warning('Subscription forbidden: ' . $ex->getMessage(), [$ex]);
} else {
$this->logger->error('Cannot send subscribe email: ' . $ex->getMessage(), [$ex]);
}
}
}

Expand Down

0 comments on commit 45326d7

Please sign in to comment.