token() === '') { return false; } try { $res = Http::withToken($this->token())->acceptJson()->timeout(30) ->post($this->base().'/messages/send', array_filter([ 'user' => $ownerPublicId, 'from' => config('smtp.from'), 'from_name' => config('smtp.from_name'), 'to' => $to, 'subject' => $subject, 'html' => $html, 'text' => $text, ])); if ($res->status() === 402) { Log::warning('Platform email send: insufficient balance', ['user' => $ownerPublicId]); return false; } if ($res->failed()) { Log::warning('Platform email send failed', ['status' => $res->status(), 'body' => $res->body()]); return false; } return (bool) ($res->json('success') ?? true); } catch (\Throwable $e) { Log::warning('Platform email send error', ['error' => $e->getMessage()]); return false; } } }