whereNull('delivered_at') ->whereNotNull('recipient_email') ->where('recipient_email', '!=', '') ->oldest() ->limit(max(1, min($limit, 100))) ->get(); foreach ($pending as $outbox) { $plain = Crypt::decryptString($outbox->encrypted_license_key); $recipient = strtolower(trim((string) $outbox->recipient_email)); if ($recipient === '') { continue; } Mail::raw( "Thank you for choosing Rsync Studio.\n\nYour licence key is:\n\n{$plain}\n\nOpen Rsync Studio → Settings → Licence and enter this key to activate your Mac.\n\nKeep this key private. You can manage activations from the Rsync Studio licence portal.", fn ($message) => $message->to($recipient)->subject('Your Rsync Studio licence key') ); $outbox->update(['delivered_at' => now()]); $delivered++; } return $delivered; } }