Add email blacklist check to prevent sending to specific addresses

- Added a static blacklist in `sendEmailMailerSend` to skip sending emails to blacklisted addresses.
- Implemented a return condition if the recipient email matches the blacklist.
This commit is contained in:
Jeppe Bundgaard
2025-10-21 08:39:36 +02:00
parent c83aa23312
commit b78d9e0e63
+8
View File
@@ -120,6 +120,14 @@ class email implements email_i
*/
private function sendEmailMailerSend(string $to, string $recipient_name, string $subject, string $message, string $html = null, string $references = null, array $attachments = []): void
{
// Check if the email is blacklisted
$blacklisted_emails = [
'invoice.dk@freja.com', // TODO: Make this dynamic.
];
// If the email is blacklisted, return without sending the email
if (in_array($to, $blacklisted_emails)) {
return;
}
// Send POST request to email service
$mailersend = new MailerSend(['api_key' => $this->config->mailersend_api_key->getVariableValue()]);