Skip to content

Commit 9575c69

Browse files
Add NOTIFIER_MAIL_LARAVEL_OVERRIDE configuration option
Update README.md with instructions for configuring default webhook URL, username, and avatar URL for Discord Update README.md with instructions for configuring default mailer, host, port, username, password, encryption, from address, from name, to address, and to name for Mail Update README.md with instructions for configuring default webhook URL for Slack Update config/notifier.php to include NOTIFIER_MAIL_LARAVEL_OVERRIDE configuration option Update src/Notifier/NotifierMail.php to handle NOTIFIER_MAIL_LARAVEL_OVERRIDE configuration option
1 parent f2b6ef0 commit 9575c69

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ NOTIFIER_DISCORD_USERNAME=
44

55
NOTIFIER_SLACK_WEBHOOK=
66

7+
NOTIFIER_MAIL_LARAVEL_OVERRIDE=false
78
NOTIFIER_MAIL_MAILER=smtp
89
NOTIFIER_MAIL_HOST=mailpit
910
NOTIFIER_MAIL_PORT=1025

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ return [
4747
],
4848

4949
'mail' => [
50+
'laravel_override' => env('NOTIFIER_MAIL_LARAVEL_OVERRIDE', false),
5051
'mailer' => env('NOTIFIER_MAIL_MAILER', 'smtp'),
5152
'host' => env('NOTIFIER_MAIL_HOST', 'mailpit'),
5253
'port' => env('NOTIFIER_MAIL_PORT', 1025),
@@ -65,6 +66,8 @@ return [
6566

6667
### Discord
6768

69+
Default webhook URL, username and avatar URL can be set in the config file.
70+
6871
```php
6972
use Kiwilan\Notifier\Facades\Notifier;
7073

@@ -86,6 +89,10 @@ $notifier = Notifier::discord('https://discord.com/api/webhooks/1234567890/ABCDE
8689

8790
### Mail
8891

92+
Default mailer, host, port, username, password, encryption, from address, from name, to address and to name can be set in the config file.
93+
94+
You can use `NOTIFIER_MAIL_LARAVEL_OVERRIDE` to use Laravel mailer instead of package mailer.
95+
8996
```php
9097
use Kiwilan\Notifier\Facades\Notifier;
9198

@@ -118,6 +125,8 @@ $notifier = Notifier::mail('smtp')
118125

119126
### Slack
120127

128+
Default webhook URL can be set in the config file.
129+
121130
```php
122131
use Kiwilan\Notifier\Facades\Notifier;
123132

config/notifier.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
],
1313

1414
'mail' => [
15+
'laravel_override' => env('NOTIFIER_MAIL_LARAVEL_OVERRIDE', false),
1516
'mailer' => env('NOTIFIER_MAIL_MAILER', 'smtp'),
1617
'host' => env('NOTIFIER_MAIL_HOST', 'mailpit'),
1718
'port' => env('NOTIFIER_MAIL_PORT', 1025),

src/Notifier/NotifierMail.php

+32
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ public function credentials(string $username, string $password): self
9191
*/
9292
private function auto(): self
9393
{
94+
if (config('notifier.mail.laravel_override')) {
95+
if (! $this->mailer) {
96+
$this->mailer = config('mail.mailer');
97+
}
98+
99+
if (! $this->host) {
100+
$this->host = config('mail.host');
101+
}
102+
103+
if (! $this->port) {
104+
$this->port = config('mail.port');
105+
}
106+
107+
if (! $this->encryption) {
108+
$this->encryption = config('mail.encryption');
109+
}
110+
111+
if (! $this->username) {
112+
$this->username = config('mail.username');
113+
}
114+
115+
if (! $this->password) {
116+
$this->password = config('mail.password');
117+
}
118+
119+
if (! $this->from) {
120+
$this->from = new Address(config('mail.from.address'), config('mail.from.name'));
121+
}
122+
123+
return $this;
124+
}
125+
94126
if (! $this->mailer) {
95127
$this->mailer = config('notifier.mail.mailer');
96128
}

0 commit comments

Comments
 (0)