diff --git a/app/Console/Commands/TestEmail.php b/app/Console/Commands/TestEmail.php index 4e29d7962..33129350a 100644 --- a/app/Console/Commands/TestEmail.php +++ b/app/Console/Commands/TestEmail.php @@ -7,6 +7,7 @@ use App\Models\ApplicationPreview; use App\Models\ScheduledDatabaseBackup; use App\Models\StandalonePostgresql; +use App\Models\Team; use App\Models\TeamInvitation; use App\Models\User; use App\Models\Waitlist; @@ -62,9 +63,13 @@ public function handle() 'invitation-link' => 'Invitation Link', 'waitlist-invitation-link' => 'Waitlist Invitation Link', 'waitlist-confirmation' => 'Waitlist Confirmation', + 'realusers-before-trial' => 'REAL - Registered Users Before Trial without Subscription', ], ); - $this->email = text('Email Address to send to'); + $emailsGathered = ['realusers-before-trial']; + if (!in_array($type, $emailsGathered)) { + $this->email = text('Email Address to send to'); + } set_transanctional_email_settings(); $this->mail = new MailMessage(); @@ -159,16 +164,39 @@ public function handle() $found = Waitlist::where('email', $this->email)->first(); if ($found) { SendConfirmationForWaitlistJob::dispatch($this->email, $found->uuid); - } else { throw new Exception('Waitlist not found'); } break; + case 'realusers-before-trial': + $this->mail = new MailMessage(); + $this->mail->view('emails.before-trial-conversion'); + $this->mail->subject('Trial period has been added for all subscription plans.'); + $teams = Team::doesntHave('subscription')->where('id', '!=', 0)->get(); + if (!$teams || $teams->isEmpty()) { + echo 'No teams found.' . PHP_EOL; + return; + } + $emails = []; + foreach ($teams as $team) { + foreach($team->members as $member) { + if ($member->email) { + $emails[] = $member->email; + } + } + } + $emails = array_unique($emails); + foreach ($emails as $email) { + $this->sendEmail($email); + } } } - private function sendEmail() + private function sendEmail(string $email = null) { + if ($email) { + $this->email = $email; + } Mail::send( [], [], diff --git a/resources/views/emails/before-trial-conversion.blade.php b/resources/views/emails/before-trial-conversion.blade.php new file mode 100644 index 000000000..c9531ff2b --- /dev/null +++ b/resources/views/emails/before-trial-conversion.blade.php @@ -0,0 +1,8 @@ + +We would like to inform you that a {{config('constants.limits.trial_period')}} days of trial has been added to all subscription plans. + +You can try out Coolify, without payment information for free. If you like it, you can upgrade to a paid plan at any time. + +[Click here](https://app.coolify.io/subscription) to start your trial. + +