Skip to content

Commit bac1329

Browse files
Allow multiple email addresses (#74)
* Add possibility to use multiple email addresses * Add test case for email list Co-authored-by: Stefan Damjanovic <>
1 parent fca549e commit bac1329

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ return [
7373
'channels' => ['mail', 'slack'],
7474

7575
'mail' => [
76-
'to' => '[email protected]',
76+
'to' => ['[email protected]'],
7777
],
7878

7979
'slack' => [

config/failed-job-monitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'channels' => ['mail', 'slack'],
2828

2929
'mail' => [
30-
'to' => '[email protected]',
30+
'to' => ['[email protected]'],
3131
],
3232

3333
'slack' => [

src/Notifiable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ class Notifiable
88
{
99
use NotifiableTrait;
1010

11-
public function routeNotificationForMail(): string
11+
public function routeNotificationForMail(): array
1212
{
13-
return config('failed-job-monitor.mail.to');
13+
$recipients = config('failed-job-monitor.mail.to');
14+
15+
if (is_string($recipients)) {
16+
return [$recipients];
17+
}
18+
19+
return $recipients;
1420
}
1521

1622
public function routeNotificationForSlack(): string

tests/NotifiableTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Spatie\FailedJobMonitor\Test;
4+
5+
use Spatie\FailedJobMonitor\Notifiable;
6+
7+
class NotifiableTest extends TestCase
8+
{
9+
/** @test */
10+
public function it_returns_always_list_of_emails()
11+
{
12+
$notifiable = new Notifiable();
13+
14+
$this->app['config']->set('failed-job-monitor.mail.to', '[email protected]');
15+
$this->assertEquals(['[email protected]'], $notifiable->routeNotificationForMail());
16+
17+
$recipients = ['[email protected]', '[email protected]'];
18+
$this->app['config']->set('failed-job-monitor.mail.to', $recipients);
19+
$this->assertEquals($recipients, $notifiable->routeNotificationForMail());
20+
}
21+
}

0 commit comments

Comments
 (0)