An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: New email notification settings
peaklabs-deva6086ee38ba8
diff --git a/app/Livewire/Notifications/Email.php b/app/Livewire/Notifications/Email.phpindex ab37686438..d81535a807 100644--- a/app/Livewire/Notifications/Email.php+++ b/app/Livewire/Notifications/Email.php@@ -19,9 +19,6 @@ class Email extends Component#[Validate(['boolean'])]public bool $smtpEnabled = false;- #[Validate(['boolean'])]- public bool $useInstanceEmailSettings = false;-#[Validate(['nullable', 'email'])]public ?string $smtpFromAddress = null;@@ -50,28 +47,46 @@ class Email extends Componentpublic ?int $smtpTimeout = null;#[Validate(['boolean'])]- public bool $smtpNotificationsTest = false;+ public bool $resendEnabled = false;++ #[Validate(['nullable', 'string'])]+ public ?string $resendApiKey = null;#[Validate(['boolean'])]- public bool $smtpNotificationsDeployments = false;+ public bool $useInstanceEmailSettings = false;#[Validate(['boolean'])]- public bool $smtpNotificationsStatusChanges = false;+ public bool $deploymentSuccessEmailNotifications = false;#[Validate(['boolean'])]- public bool $smtpNotificationsDatabaseBackups = false;+ public bool $deploymentFailureEmailNotifications = true;#[Validate(['boolean'])]- public bool $smtpNotificationsScheduledTasks = false;+ public bool $statusChangeEmailNotifications = false;#[Validate(['boolean'])]- public bool $smtpNotificationsServerDiskUsage = false;+ public bool $backupSuccessEmailNotifications = false;#[Validate(['boolean'])]- public bool $resendEnabled;+ public bool $backupFailureEmailNotifications = true;- #[Validate(['nullable', 'string'])]- public ?string $resendApiKey = null;+ #[Validate(['boolean'])]+ public bool $scheduledTaskSuccessEmailNotifications = false;++ #[Validate(['boolean'])]+ public bool $scheduledTaskFailureEmailNotifications = true;++ #[Validate(['boolean'])]+ public bool $dockerCleanupEmailNotifications = false;++ #[Validate(['boolean'])]+ public bool $serverDiskUsageEmailNotifications = true;++ #[Validate(['boolean'])]+ public bool $serverReachableEmailNotifications = false;++ #[Validate(['boolean'])]+ public bool $serverUnreachableEmailNotifications = true;#[Validate(['nullable', 'email'])]public ?string $testEmailAddress = null;@@ -91,47 +106,67 @@ class Email extends Component{if ($toModel) {$this->validate();- $this->team->smtp_enabled = $this->smtpEnabled;- $this->team->smtp_from_address = $this->smtpFromAddress;- $this->team->smtp_from_name = $this->smtpFromName;- $this->team->smtp_host = $this->smtpHost;- $this->team->smtp_port = $this->smtpPort;- $this->team->smtp_encryption = $this->smtpEncryption;- $this->team->smtp_username = $this->smtpUsername;- $this->team->smtp_password = $this->smtpPassword;- $this->team->smtp_timeout = $this->smtpTimeout;- $this->team->smtp_recipients = $this->smtpRecipients;- $this->team->smtp_notifications_test = $this->smtpNotificationsTest;- $this->team->smtp_notifications_deployments = $this->smtpNotificationsDeployments;- $this->team->smtp_notifications_status_changes = $this->smtpNotificationsStatusChanges;- $this->team->smtp_notifications_database_backups = $this->smtpNotificationsDatabaseBackups;- $this->team->smtp_notifications_scheduled_tasks = $this->smtpNotificationsScheduledTasks;- $this->team->smtp_notifications_server_disk_usage = $this->smtpNotificationsServerDiskUsage;- $this->team->use_instance_email_settings = $this->useInstanceEmailSettings;- $this->team->resend_enabled = $this->resendEnabled;- $this->team->resend_api_key = $this->resendApiKey;- $this->team->save();+ $settings = $this->team->emailNotificationSettings;+ $settings->smtp_enabled = $this->smtpEnabled;+ $settings->smtp_from_address = $this->smtpFromAddress;+ $settings->smtp_from_name = $this->smtpFromName;+ $settings->smtp_recipients = $this->smtpRecipients;+ $settings->smtp_host = $this->smtpHost;+ $settings->smtp_port = $this->smtpPort;+ $settings->smtp_encryption = $this->smtpEncryption;+ $settings->smtp_username = $this->smtpUsername;+ $settings->smtp_password = $this->smtpPassword;+ $settings->smtp_timeout = $this->smtpTimeout;++ $settings->resend_enabled = $this->resendEnabled;+ $settings->resend_api_key = $this->resendApiKey;++ $settings->use_instance_email_settings = $this->useInstanceEmailSettings;++ $settings->deployment_success_email_notifications = $this->deploymentSuccessEmailNotifications;+ $settings->deployment_failure_email_notifications = $this->deploymentFailureEmailNotifications;+ $settings->status_change_email_notifications = $this->statusChangeEmailNotifications;+ $settings->backup_success_email_notifications = $this->backupSuccessEmailNotifications;+ $settings->backup_failure_email_notifications = $this->backupFailureEmailNotifications;+ $settings->scheduled_task_success_email_notifications = $this->scheduledTaskSuccessEmailNotifications;+ $settings->scheduled_task_failure_email_notifications = $this->scheduledTaskFailureEmailNotifications;+ $settings->docker_cleanup_email_notifications = $this->dockerCleanupEmailNotifications;+ $settings->server_disk_usage_email_notifications = $this->serverDiskUsageEmailNotifications;+ $settings->server_reachable_email_notifications = $this->serverReachableEmailNotifications;+ $settings->server_unreachable_email_notifications = $this->serverUnreachableEmailNotifications;++ $settings->save();refreshSession();} else {- $this->smtpEnabled = $this->team->smtp_enabled;- $this->smtpFromAddress = $this->team->smtp_from_address;- $this->smtpFromName = $this->team->smtp_from_name;- $this->smtpHost = $this->team->smtp_host;- $this->smtpPort = $this->team->smtp_port;- $this->smtpEncryption = $this->team->smtp_encryption;- $this->smtpUsername = $this->team->smtp_username;- $this->smtpPassword = $this->team->smtp_password;- $this->smtpTimeout = $this->team->smtp_timeout;- $this->smtpRecipients = $this->team->smtp_recipients;- $this->smtpNotificationsTest = $this->team->smtp_notifications_test;- $this->smtpNotificationsDeployments = $this->team->smtp_notifications_deployments;- $this->smtpNotificationsStatusChanges = $this->team->smtp_notifications_status_changes;- $this->smtpNotificationsDatabaseBackups = $this->team->smtp_notifications_database_backups;- $this->smtpNotificationsScheduledTasks = $this->team->smtp_notifications_scheduled_tasks;- $this->smtpNotificationsServerDiskUsage = $this->team->smtp_notifications_server_disk_usage;- $this->useInstanceEmailSettings = $this->team->use_instance_email_settings;- $this->resendEnabled = $this->team->resend_enabled;- $this->resendApiKey = $this->team->resend_api_key;+ $settings = $this->team->emailNotificationSettings;++ $this->smtpEnabled = $settings->smtp_enabled;+ $this->smtpFromAddress = $settings->smtp_from_address;+ $this->smtpFromName = $settings->smtp_from_name;+ $this->smtpRecipients = $settings->smtp_recipients;+ $this->smtpHost = $settings->smtp_host;+ $this->smtpPort = $settings->smtp_port;+ $this->smtpEncryption = $settings->smtp_encryption;+ $this->smtpUsername = $settings->smtp_username;+ $this->smtpPassword = $settings->smtp_password;+ $this->smtpTimeout = $settings->smtp_timeout;++ $this->resendEnabled = $settings->resend_enabled;+ $this->resendApiKey = $settings->resend_api_key;++ $this->useInstanceEmailSettings = $settings->use_instance_email_settings;++ $this->deploymentSuccessEmailNotifications = $settings->deployment_success_email_notifications;+ $this->deploymentFailureEmailNotifications = $settings->deployment_failure_email_notifications;+ $this->statusChangeEmailNotifications = $settings->status_change_email_notifications;+ $this->backupSuccessEmailNotifications = $settings->backup_success_email_notifications;+ $this->backupFailureEmailNotifications = $settings->backup_failure_email_notifications;+ $this->scheduledTaskSuccessEmailNotifications = $settings->scheduled_task_success_email_notifications;+ $this->scheduledTaskFailureEmailNotifications = $settings->scheduled_task_failure_email_notifications;+ $this->dockerCleanupEmailNotifications = $settings->docker_cleanup_email_notifications;+ $this->serverDiskUsageEmailNotifications = $settings->server_disk_usage_email_notifications;+ $this->serverReachableEmailNotifications = $settings->server_reachable_email_notifications;+ $this->serverUnreachableEmailNotifications = $settings->server_unreachable_email_notifications;}}@@ -178,13 +213,26 @@ class Email extends Component{try {$this->validate([- 'smtpHost' => 'required',+ 'smtpEnabled' => 'boolean',+ 'smtpFromAddress' => 'required|email',+ 'smtpFromName' => 'required|string',+ 'smtpHost' => 'required|string','smtpPort' => 'required|numeric',+ 'smtpEncryption' => 'required|string|in:tls,ssl,none',+ 'smtpUsername' => 'nullable|string',+ 'smtpPassword' => 'nullable|string',+ 'smtpTimeout' => 'nullable|numeric',], [+ 'smtpFromAddress.required' => 'From Address is required.',+ 'smtpFromAddress.email' => 'Please enter a valid email address.',+ 'smtpFromName.required' => 'From Name is required.','smtpHost.required' => 'SMTP Host is required.','smtpPort.required' => 'SMTP Port is required.',+ 'smtpPort.numeric' => 'SMTP Port must be a number.',+ 'smtpEncryption.required' => 'Encryption type is required.',]);$this->resendEnabled = false;+ $this->useInstanceEmailSettings = false;$this->saveModel();} catch (\Throwable $e) {$this->smtpEnabled = false;@@ -197,11 +245,18 @@ class Email extends Component{try {$this->validate([- 'resendApiKey' => 'required',+ 'resendEnabled' => 'boolean',+ 'resendApiKey' => 'required|string',+ 'smtpFromAddress' => 'required|email',+ 'smtpFromName' => 'required|string',], ['resendApiKey.required' => 'Resend API Key is required.',+ 'smtpFromAddress.required' => 'From Address is required.',+ 'smtpFromAddress.email' => 'Please enter a valid email address.',+ 'smtpFromName.required' => 'From Name is required.',]);$this->smtpEnabled = false;+ $this->useInstanceEmailSettings = false;$this->saveModel();} catch (\Throwable $e) {$this->resendEnabled = false;@@ -258,6 +313,81 @@ class Email extends Component$this->dispatch('error', 'Instance SMTP/Resend settings are not enabled.');}+ public function submitSmtp()+ {+ try {+ $this->resetErrorBag();+ $this->validate([+ 'smtpEnabled' => 'boolean',+ 'smtpFromAddress' => 'required|email',+ 'smtpFromName' => 'required|string',+ 'smtpHost' => 'required|string',+ 'smtpPort' => 'required|numeric',+ 'smtpEncryption' => 'required|string|in:tls,ssl,none',+ 'smtpUsername' => 'nullable|string',+ 'smtpPassword' => 'nullable|string',+ 'smtpTimeout' => 'nullable|numeric',+ ], [+ 'smtpFromAddress.required' => 'From Address is required.',+ 'smtpFromAddress.email' => 'Please enter a valid email address.',+ 'smtpFromName.required' => 'From Name is required.',+ 'smtpHost.required' => 'SMTP Host is required.',+ 'smtpPort.required' => 'SMTP Port is required.',+ 'smtpPort.numeric' => 'SMTP Port must be a number.',+ 'smtpEncryption.required' => 'Encryption type is required.',+ ]);++ $settings = $this->team->emailNotificationSettings;++ $settings->smtp_enabled = $this->smtpEnabled;+ $settings->smtp_from_address = $this->smtpFromAddress;+ $settings->smtp_from_name = $this->smtpFromName;+ $settings->smtp_host = $this->smtpHost;+ $settings->smtp_port = $this->smtpPort;+ $settings->smtp_encryption = $this->smtpEncryption;+ $settings->smtp_username = $this->smtpUsername;+ $settings->smtp_password = $this->smtpPassword;+ $settings->smtp_timeout = $this->smtpTimeout;++ $settings->save();+ refreshSession();+ $this->dispatch('success', 'SMTP settings saved.');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+ }++ public function submitResend()+ {+ try {+ $this->resetErrorBag();+ $this->validate([+ 'resendEnabled' => 'boolean',+ 'resendApiKey' => 'required|string',+ 'smtpFromAddress' => 'required|email',+ 'smtpFromName' => 'required|string',+ ], [+ 'resendApiKey.required' => 'Resend API Key is required.',+ 'smtpFromAddress.required' => 'From Address is required.',+ 'smtpFromAddress.email' => 'Please enter a valid email address.',+ 'smtpFromName.required' => 'From Name is required.',+ ]);++ $settings = $this->team->emailNotificationSettings;++ $settings->resend_enabled = $this->resendEnabled;+ $settings->resend_api_key = $this->resendApiKey;+ $settings->smtp_from_address = $this->smtpFromAddress;+ $settings->smtp_from_name = $this->smtpFromName;++ $settings->save();+ refreshSession();+ $this->dispatch('success', 'Resend settings saved.');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+ }+public function render(){return view('livewire.notifications.email');diff --git a/resources/views/livewire/notifications/email.blade.php b/resources/views/livewire/notifications/email.blade.phpindex fba21d0b20..4e5d3a6477 100644--- a/resources/views/livewire/notifications/email.blade.php+++ b/resources/views/livewire/notifications/email.blade.php@@ -1,54 +1,50 @@<div><x-slot:title>Notifications | Coolify- </x-slot>- <x-notification.navbar />- <form wire:submit='submit' class="flex flex-col gap-4 pb-4">- <div class="flex items-center gap-2">- <h2>Email</h2>- <x-forms.button type="submit">- Save- </x-forms.button>- @if (isInstanceAdmin() && !$useInstanceEmailSettings)+ </x-slot>+ <x-notification.navbar />+ <form wire:submit='submit' class="flex flex-col gap-4 pb-4">+ <div class="flex items-center gap-2">+ <h2>Email</h2>+ <x-forms.button type="submit">+ Save+ </x-forms.button>+ @if (isInstanceAdmin() && !$useInstanceEmailSettings)<x-forms.button wire:click='copyFromInstanceSettings'>Copy from Instance Settings</x-forms.button>- @endif- @if (isEmailEnabled($team) && auth()->user()->isAdminFromSession() && isTestEmailEnabled($team))+ @endif+ @if (isEmailEnabled($team) && auth()->user()->isAdminFromSession())<x-modal-input buttonTitle="Send Test Email" title="Send Test Email"><form wire:submit.prevent="sendTestEmail" class="flex flex-col w-full gap-2">- <x-forms.input wire:model="testEmailAddress" placeholder="[email protected]" id="testEmailAddress"- label="Recipients" required />+ <x-forms.input wire:model="testEmailAddress" placeholder="[email protected]" id="testEmailAddress" label="Recipients" required /><x-forms.button type="submit" @click="modalOpen=false">Send Email</x-forms.button></form></x-modal-input>- @endif- </div>- @if (!isCloud())+ @endif+ </div>+ @if (!isCloud())<div class="w-96">- <x-forms.checkbox instantSave="instantSaveInstance" id="useInstanceEmailSettings"- label="Use system wide (transactional) email settings" />+ <x-forms.checkbox instantSave="instantSaveInstance" id="useInstanceEmailSettings" label="Use system wide (transactional) email settings" /></div>- @endif- @if (!$useInstanceEmailSettings)+ @endif+ @if (!$useInstanceEmailSettings)<div class="flex gap-4"><x-forms.input required id="smtpFromName" helper="Name used in emails." label="From Name" />- <x-forms.input required id="smtpFromAddress" helper="Email address used in emails."- label="From Address" />+ <x-forms.input required id="smtpFromAddress" helper="Email address used in emails." label="From Address" /></div>- @endif- </form>- @if (isCloud())+ @endif+ </form>+ @if (isCloud())<div class="w-64 py-4">- <x-forms.checkbox instantSave="instantSaveInstance" id="useInstanceEmailSettings"- label="Use Hosted Email Service" />+ <x-forms.checkbox instantSave="instantSaveInstance" id="useInstanceEmailSettings" label="Use Hosted Email Service" /></div>- @endif- @if (!$useInstanceEmailSettings)+ @endif+ @if (!$useInstanceEmailSettings)<div class="flex flex-col gap-4">- <form wire:submit='submit' class="p-4 border dark:border-coolgray-300 flex flex-col gap-2">+ <form wire:submit='submitSmtp' class="p-4 border dark:border-coolgray-300 flex flex-col gap-2"><div class="flex items-center gap-2"><h3>SMTP Server</h3><x-forms.button type="submit">@@ -72,13 +68,12 @@<div class="flex flex-col w-full gap-2 xl:flex-row"><x-forms.input id="smtpUsername" label="SMTP Username" /><x-forms.input id="smtpPassword" type="password" label="SMTP Password" />- <x-forms.input id="smtpTimeout" helper="Timeout value for sending emails."- label="Timeout" />+ <x-forms.input id="smtpTimeout" helper="Timeout value for sending emails." label="Timeout" /></div></div></div></form>- <form wire:submit='submit' class="p-4 border dark:border-coolgray-300 flex flex-col gap-2">+ <form wire:submit='submitResend' class="p-4 border dark:border-coolgray-300 flex flex-col gap-2"><div class="flex items-center gap-2"><h3>Resend</h3><x-forms.button type="submit">@@ -91,28 +86,50 @@<div class="flex flex-col"><div class="flex flex-col gap-4"><div class="flex flex-col w-full gap-2 xl:flex-row">- <x-forms.input required type="password" id="resendApiKey" placeholder="API key"- label="API Key" />+ <x-forms.input required type="password" id="resendApiKey" placeholder="API key" label="API Key" /></div></div></div></form></div>- @endif- @if (isEmailEnabled($team) || $useInstanceEmailSettings)- <h2 class="mt-4">Subscribe to events</h2>- <div class="w-64">- @if (isDev())- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsTest" label="Test" />- @endif- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsStatusChanges"- label="Container Status Changes" />- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsDeployments"- label="Application Deployments" />- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsDatabaseBackups" label="Backup Status" />- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsScheduledTasks"- label="Scheduled Tasks Status" />- <x-forms.checkbox instantSave="saveModel" id="smtpNotificationsServerDiskUsage" label="Server Disk Usage" />+ @endif+ @if (isEmailEnabled($team) || $useInstanceEmailSettings)+ <h2 class="mt-8 mb-4">Notification Settings</h2>+ <p class="mb-4">+ Select events for which you would like to receive email notifications.+ </p>+ <div class="flex flex-col gap-4 max-w-2xl">+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">+ <h3 class="font-medium mb-3">Deployments</h3>+ <div class="flex flex-col gap-1.5 pl-1">+ <x-forms.checkbox instantSave="saveModel" id="deploymentSuccessEmailNotifications" label="Deployment Success" />+ <x-forms.checkbox instantSave="saveModel" id="deploymentFailureEmailNotifications" label="Deployment Failure" />+ <x-forms.checkbox instantSave="saveModel" helper="Send an email when a container status changes. It will send and email for Stopped and Restarted events of a container." id="statusChangeEmailNotifications" label="Container Status Changes" />+ </div>+ </div>+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">+ <h3 class="font-medium mb-3">Backups</h3>+ <div class="flex flex-col gap-1.5 pl-1">+ <x-forms.checkbox instantSave="saveModel" id="backupSuccessEmailNotifications" label="Backup Success" />+ <x-forms.checkbox instantSave="saveModel" id="backupFailureEmailNotifications" label="Backup Failure" />+ </div>+ </div>+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">+ <h3 class="font-medium mb-3">Scheduled Tasks</h3>+ <div class="flex flex-col gap-1.5 pl-1">+ <x-forms.checkbox instantSave="saveModel" id="scheduledTaskSuccessEmailNotifications" label="Scheduled Task Success" />+ <x-forms.checkbox instantSave="saveModel" id="scheduledTaskFailureEmailNotifications" label="Scheduled Task Failure" />+ </div>+ </div>+ <div class="border dark:border-coolgray-300 p-4 rounded-lg">+ <h3 class="font-medium mb-3">Server</h3>+ <div class="flex flex-col gap-1.5 pl-1">+ <x-forms.checkbox instantSave="saveModel" helper="Send an email when Docker Cleanup is run on a server." id="dockerCleanupEmailNotifications" label="Docker Cleanup" />+ <x-forms.checkbox instantSave="saveModel" helper="Send an email when server disk usage is high." id="serverDiskUsageEmailNotifications" label="Server Disk Usage" />+ <x-forms.checkbox instantSave="saveModel" id="serverReachableEmailNotifications" label="Server Reachable" />+ <x-forms.checkbox instantSave="saveModel" id="serverUnreachableEmailNotifications" label="Server Unreachable" />+ </div>+ </div></div>- @endif+ @endif</div>