This commit is contained in:
Joao Patricio 2023-05-23 12:32:11 +01:00
parent 13fda50aac
commit aea6bced69
9 changed files with 92 additions and 13 deletions

View File

@ -29,7 +29,7 @@ public function submit()
} }
public function sentTestMessage() public function sentTestMessage()
{ {
// @TODO figure out how to do it in runtime Notification::send(auth()->user(), new TestMessage);
} }
public function render() public function render()
{ {

View File

@ -40,7 +40,7 @@ public function submit()
} }
public function sentTestMessage() public function sentTestMessage()
{ {
Notification::send(auth()->user(), new TestMessage);
} }
public function render() public function render()
{ {

53
app/Mail/ExampleMail.php Normal file
View File

@ -0,0 +1,53 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class ExampleMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct()
{
//
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Example Mail',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'emails.example',
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

View File

@ -35,6 +35,24 @@ public function via(object $notifiable): array
*/ */
public function toMail(object $notifiable): MailMessage 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) return (new MailMessage)
->line('Welcome to Coolify!') ->line('Welcome to Coolify!')
->action('Go to dashboard', url('/')) ->action('Go to dashboard', url('/'))
@ -43,6 +61,7 @@ public function toMail(object $notifiable): MailMessage
public function toDiscord(object $notifiable): string public function toDiscord(object $notifiable): string
{ {
ray('1111');
return 'Welcome to Coolify! We need your attention for disk usage. [Go to dashboard]('.url('/').')'; return 'Welcome to Coolify! We need your attention for disk usage. [Go to dashboard]('.url('/').')';
} }

View File

@ -21,8 +21,6 @@ services:
SSL_MODE: "off" SSL_MODE: "off"
AUTORUN_LARAVEL_STORAGE_LINK: "false" AUTORUN_LARAVEL_STORAGE_LINK: "false"
AUTORUN_LARAVEL_MIGRATION: "false" AUTORUN_LARAVEL_MIGRATION: "false"
env_file:
- .env
volumes: volumes:
- .:/var/www/html/:cached - .:/var/www/html/:cached
postgres: postgres:

View File

@ -0,0 +1 @@
Hello I am an example

View File

@ -12,10 +12,13 @@
<x-inputs.input id="settings.extra_attributes.smtp_timeout" label="Timeout" /> <x-inputs.input id="settings.extra_attributes.smtp_timeout" label="Timeout" />
</div> </div>
</div> </div>
<div> <div class="flex">
<x-inputs.button class="w-16 mt-4" type="submit"> <x-inputs.button class="w-16 mt-4" type="submit">
Submit Submit
</x-inputs.button> </x-inputs.button>
</div>
<div class="mt-10 flex flex-col w-96">
<x-inputs.input id="settings.extra_attributes.smtp_username" label="Send a test e-mail to:" />
<x-inputs.button class="mt-4 btn btn-xs no-animation normal-case text-white btn-primary" wire:click="sentTestMessage"> <x-inputs.button class="mt-4 btn btn-xs no-animation normal-case text-white btn-primary" wire:click="sentTestMessage">
Send test message Send test message
</x-inputs.button> </x-inputs.button>

View File

@ -4,9 +4,11 @@
<h3>General</h3> <h3>General</h3>
<livewire:settings.form :settings="$settings" /> <livewire:settings.form :settings="$settings" />
<div class="my-12"></div> <div class="h-12"></div>
<h3>Notifications</h3> <h3>Notifications</h3>
<livewire:settings.discord-notifications :settings="$settings" /> <livewire:settings.discord-notifications :settings="$settings" />
<livewire:settings.email-notifications :settings="$settings" /> <livewire:settings.email-notifications :settings="$settings" />
<div class="h-12"></div>
</x-layout> </x-layout>

View File

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mailer\Mailer;
@ -29,13 +30,15 @@
]; ];
config()->set('mail.mailers.smtp', $smtp); config()->set('mail.mailers.smtp', $smtp);
// \Illuminate\Support\Facades\Mail::mailer('smtp') // For testing custom SMTP Mailer
// ->to('ask@me.com') \Illuminate\Support\Facades\Mail::mailer('smtp')
// ->send(new \App\Mail\TestMail); ->to('ask@me.com')
->send(new \App\Mail\ExampleMail);
\Illuminate\Support\Facades\Notification::send( // For sending a notification
\App\Models\User::find(1), // \Illuminate\Support\Facades\Notification::send(
new \App\Notifications\TestMessage // \App\Models\User::find(1),
); // new \App\Notifications\TestMessage
// );
})->purpose('Display an inspiring quote'); })->purpose('Display an inspiring quote');