Skip to content

Commit a3f3470

Browse files
committed
add resend as mailer
1 parent b7ec1d7 commit a3f3470

File tree

4 files changed

+147
-14
lines changed

4 files changed

+147
-14
lines changed

app/Notifications/Channels/EmailChannel.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
use Illuminate\Mail\Message;
77
use Illuminate\Notifications\Notification;
88
use Illuminate\Support\Facades\Mail;
9+
use Illuminate\Support\Str;
910

1011
class EmailChannel
1112
{
1213
public function send(SendsEmail $notifiable, Notification $notification): void
1314
{
1415
$this->bootConfigs($notifiable);
15-
ray($notification);
1616
$recepients = $notifiable->getRecepients($notification);
1717

1818
if (count($recepients) === 0) {
@@ -39,16 +39,21 @@ private function bootConfigs($notifiable): void
3939
$password = data_get($notifiable, 'smtp_password');
4040
if ($password) $password = decrypt($password);
4141

42-
config()->set('mail.default', 'smtp');
43-
config()->set('mail.mailers.smtp', [
44-
"transport" => "smtp",
45-
"host" => data_get($notifiable, 'smtp_host'),
46-
"port" => data_get($notifiable, 'smtp_port'),
47-
"encryption" => data_get($notifiable, 'smtp_encryption'),
48-
"username" => data_get($notifiable, 'smtp_username'),
49-
"password" => $password,
50-
"timeout" => data_get($notifiable, 'smtp_timeout'),
51-
"local_domain" => null,
52-
]);
42+
if (Str::contains(data_get($notifiable, 'smtp_host'),'resend.com')) {
43+
config()->set('mail.default', 'resend');
44+
config()->set('resend.api_key', $password);
45+
} else {
46+
config()->set('mail.default', 'smtp');
47+
config()->set('mail.mailers.smtp', [
48+
"transport" => "smtp",
49+
"host" => data_get($notifiable, 'smtp_host'),
50+
"port" => data_get($notifiable, 'smtp_port'),
51+
"encryption" => data_get($notifiable, 'smtp_encryption'),
52+
"username" => data_get($notifiable, 'smtp_username'),
53+
"password" => $password,
54+
"timeout" => data_get($notifiable, 'smtp_timeout'),
55+
"local_domain" => null,
56+
]);
57+
}
5358
}
5459
}

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"masmerise/livewire-toaster": "^1.2",
2525
"nubs/random-name-generator": "^2.2",
2626
"poliander/cron": "^3.0",
27+
"resend/resend-laravel": "^0.5.0",
2728
"sentry/sentry-laravel": "^3.4",
2829
"spatie/laravel-activitylog": "^4.7.3",
2930
"spatie/laravel-data": "^3.4.3",

composer.lock

+126-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/mail.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
'timeout' => null,
4545
'local_domain' => env('MAIL_EHLO_DOMAIN'),
4646
],
47-
47+
'resend'=> [
48+
'transport' => 'resend'
49+
],
4850
'ses' => [
4951
'transport' => 'ses',
5052
],

0 commit comments

Comments
 (0)