add resend as mailer

This commit is contained in:
Andras Bacsai 2023-08-21 11:11:51 +02:00
parent b7ec1d7d65
commit a3f3470137
4 changed files with 147 additions and 14 deletions

View File

@ -6,13 +6,13 @@
use Illuminate\Mail\Message;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
class EmailChannel
{
public function send(SendsEmail $notifiable, Notification $notification): void
{
$this->bootConfigs($notifiable);
ray($notification);
$recepients = $notifiable->getRecepients($notification);
if (count($recepients) === 0) {
@ -39,6 +39,10 @@ private function bootConfigs($notifiable): void
$password = data_get($notifiable, 'smtp_password');
if ($password) $password = decrypt($password);
if (Str::contains(data_get($notifiable, 'smtp_host'),'resend.com')) {
config()->set('mail.default', 'resend');
config()->set('resend.api_key', $password);
} else {
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
"transport" => "smtp",
@ -51,4 +55,5 @@ private function bootConfigs($notifiable): void
"local_domain" => null,
]);
}
}
}

View File

@ -24,6 +24,7 @@
"masmerise/livewire-toaster": "^1.2",
"nubs/random-name-generator": "^2.2",
"poliander/cron": "^3.0",
"resend/resend-laravel": "^0.5.0",
"sentry/sentry-laravel": "^3.4",
"spatie/laravel-activitylog": "^4.7.3",
"spatie/laravel-data": "^3.4.3",

127
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0c023bed552776ee5e4eeda1ff0a5e19",
"content-hash": "15eb89e93c667bb63f48ef548ed38bed",
"packages": [
{
"name": "aws/aws-crt-php",
@ -5404,6 +5404,131 @@
],
"time": "2023-04-15T23:01:58+00:00"
},
{
"name": "resend/resend-laravel",
"version": "v0.5.0",
"source": {
"type": "git",
"url": "https://github.com/resendlabs/resend-laravel.git",
"reference": "e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/resendlabs/resend-laravel/zipball/e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d",
"reference": "e598d1e25e49a7aa4c35f653d1d828f69ee4fc1d",
"shasum": ""
},
"require": {
"illuminate/support": "^9.21|^10.0",
"php": "^8.1",
"resend/resend-php": "^0.7.1",
"symfony/mailer": "^6.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.14",
"mockery/mockery": "^1.5",
"orchestra/testbench": "^7.22|^8.0",
"pestphp/pest": "^1.22"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
},
"laravel": {
"providers": [
"Resend\\Laravel\\ResendServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Resend\\Laravel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Resend and contributors",
"homepage": "https://github.com/resendlabs/resend-laravel/contributors"
}
],
"description": "Resend for Laravel",
"homepage": "https://resend.com/",
"keywords": [
"api",
"client",
"laravel",
"php",
"resend",
"sdk"
],
"support": {
"issues": "https://github.com/resendlabs/resend-laravel/issues",
"source": "https://github.com/resendlabs/resend-laravel/tree/v0.5.0"
},
"time": "2023-07-15T17:56:14+00:00"
},
{
"name": "resend/resend-php",
"version": "v0.7.1",
"source": {
"type": "git",
"url": "https://github.com/resendlabs/resend-php.git",
"reference": "3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/resendlabs/resend-php/zipball/3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0",
"reference": "3b2e2eae0ded191b2ea67d0ee2e87cdc442316a0",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^7.5",
"php": "^8.1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.13",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-mock": "^2.0"
},
"type": "library",
"autoload": {
"files": [
"src/Resend.php"
],
"psr-4": {
"Resend\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Resend and contributors",
"homepage": "https://github.com/resendlabs/resend-php/contributors"
}
],
"description": "Resend PHP library.",
"homepage": "https://resend.com/",
"keywords": [
"api",
"client",
"php",
"resend",
"sdk"
],
"support": {
"issues": "https://github.com/resendlabs/resend-php/issues",
"source": "https://github.com/resendlabs/resend-php/tree/v0.7.1"
},
"time": "2023-07-12T07:08:27+00:00"
},
{
"name": "sentry/sdk",
"version": "3.5.0",

View File

@ -44,7 +44,9 @@
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'resend'=> [
'transport' => 'resend'
],
'ses' => [
'transport' => 'ses',
],