From aea6bced69c0aa79156305075b968591605a6dbb Mon Sep 17 00:00:00 2001 From: Joao Patricio Date: Tue, 23 May 2023 12:32:11 +0100 Subject: [PATCH] wip --- .../Settings/DiscordNotifications.php | 2 +- .../Livewire/Settings/EmailNotifications.php | 2 +- app/Mail/ExampleMail.php | 53 +++++++++++++++++++ app/Notifications/TestMessage.php | 19 +++++++ docker-compose.dev.yml | 2 - resources/views/emails/example.blade.php | 1 + .../settings/email-notifications.blade.php | 5 +- resources/views/settings.blade.php | 4 +- routes/console.php | 17 +++--- 9 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 app/Mail/ExampleMail.php create mode 100644 resources/views/emails/example.blade.php diff --git a/app/Http/Livewire/Settings/DiscordNotifications.php b/app/Http/Livewire/Settings/DiscordNotifications.php index 01388a238..4227c2276 100644 --- a/app/Http/Livewire/Settings/DiscordNotifications.php +++ b/app/Http/Livewire/Settings/DiscordNotifications.php @@ -29,7 +29,7 @@ public function submit() } public function sentTestMessage() { - // @TODO figure out how to do it in runtime + Notification::send(auth()->user(), new TestMessage); } public function render() { diff --git a/app/Http/Livewire/Settings/EmailNotifications.php b/app/Http/Livewire/Settings/EmailNotifications.php index 639fb11cd..b1bca81c8 100644 --- a/app/Http/Livewire/Settings/EmailNotifications.php +++ b/app/Http/Livewire/Settings/EmailNotifications.php @@ -40,7 +40,7 @@ public function submit() } public function sentTestMessage() { - Notification::send(auth()->user(), new TestMessage); + } public function render() { diff --git a/app/Mail/ExampleMail.php b/app/Mail/ExampleMail.php new file mode 100644 index 000000000..0167b26e1 --- /dev/null +++ b/app/Mail/ExampleMail.php @@ -0,0 +1,53 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Notifications/TestMessage.php b/app/Notifications/TestMessage.php index 8e8929f10..717f6ce08 100644 --- a/app/Notifications/TestMessage.php +++ b/app/Notifications/TestMessage.php @@ -35,6 +35,24 @@ public function via(object $notifiable): array */ public function toMail(object $notifiable): MailMessage { + $smtp = [ + "transport" => "smtp", + "host" => "mailpit", + "port" => 1025, + "encryption" => 'tls', + "username" => null, + "password" => null, + "timeout" => null, + "local_domain" => null, + ]; + config()->set('mail.mailers.smtp', $smtp); + + \Illuminate\Support\Facades\Mail::mailer('smtp') + ->to('ask@me.com') + ->send(new \App\Mail\ExampleMail); + + + return (new MailMessage) ->line('Welcome to Coolify!') ->action('Go to dashboard', url('/')) @@ -43,6 +61,7 @@ public function toMail(object $notifiable): MailMessage public function toDiscord(object $notifiable): string { + ray('1111'); return 'Welcome to Coolify! We need your attention for disk usage. [Go to dashboard]('.url('/').')'; } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 76065370c..4a9b3c0f9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -21,8 +21,6 @@ services: SSL_MODE: "off" AUTORUN_LARAVEL_STORAGE_LINK: "false" AUTORUN_LARAVEL_MIGRATION: "false" - env_file: - - .env volumes: - .:/var/www/html/:cached postgres: diff --git a/resources/views/emails/example.blade.php b/resources/views/emails/example.blade.php new file mode 100644 index 000000000..bbfbe24b1 --- /dev/null +++ b/resources/views/emails/example.blade.php @@ -0,0 +1 @@ +Hello I am an example diff --git a/resources/views/livewire/settings/email-notifications.blade.php b/resources/views/livewire/settings/email-notifications.blade.php index 6bfc53506..4f3af4156 100644 --- a/resources/views/livewire/settings/email-notifications.blade.php +++ b/resources/views/livewire/settings/email-notifications.blade.php @@ -12,10 +12,13 @@ -
+
Submit +
+
+ Send test message diff --git a/resources/views/settings.blade.php b/resources/views/settings.blade.php index f0155603d..dbd8588f1 100644 --- a/resources/views/settings.blade.php +++ b/resources/views/settings.blade.php @@ -4,9 +4,11 @@

General

-
+

Notifications

+ +
diff --git a/routes/console.php b/routes/console.php index 34f661adb..2de1715be 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,6 +1,7 @@ set('mail.mailers.smtp', $smtp); -// \Illuminate\Support\Facades\Mail::mailer('smtp') -// ->to('ask@me.com') -// ->send(new \App\Mail\TestMail); + // For testing custom SMTP Mailer + \Illuminate\Support\Facades\Mail::mailer('smtp') + ->to('ask@me.com') + ->send(new \App\Mail\ExampleMail); - \Illuminate\Support\Facades\Notification::send( - \App\Models\User::find(1), - new \App\Notifications\TestMessage - ); + // For sending a notification +// \Illuminate\Support\Facades\Notification::send( +// \App\Models\User::find(1), +// new \App\Notifications\TestMessage +// ); })->purpose('Display an inspiring quote');