Skip to content

Commit

Permalink
Add whitelist domains (#15)
Browse files Browse the repository at this point in the history
* add whitelisted domains

* Update src/SailthruChannel.php

Co-authored-by: Thomas Omweri <thomaso@ringier.co.za>

* rename

* sort in alphabetical order

* cleanup

---------

Co-authored-by: Thomas Omweri <thomaso@ringier.co.za>
  • Loading branch information
thamibn and thomasmokuaomweri2011 authored Mar 26, 2024
1 parent febff6a commit 4495a32
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/SailthruChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Sailthru_Client_Exception;

class SailthruChannel
Expand Down Expand Up @@ -67,6 +68,23 @@ public function send(
static::getDefaultVars()
);

if (config('services.sailthru.whitelist_check.enabled') === true) {
if(!Str::is(
config('services.sailthru.whitelist_check.domains'),
$message->getToEmail()
)){
Log::info(
'Sailthru email not sent to ' . $message->getToEmail() . ' due to domain whitelist limitations',
[
'notifiable' => $notifiable,
'notification' => $notification,
]
);

return [];
}
}

$response = $message->isMultiSend()
? $this->multiSend($message)
: $this->singleSend($message);
Expand Down

0 comments on commit 4495a32

Please sign in to comment.