Surface platform SMTP errors on speaker invitation failures.
Deploy Ladill Events / deploy (push) Successful in 44s

Return the Bird API error instead of a generic wallet message so domain and balance issues are actionable.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-03 16:23:09 +00:00
co-authored by Cursor
parent 99ffc510f9
commit 1db499ba2f
3 changed files with 21 additions and 1 deletions
@@ -7,6 +7,13 @@ use Illuminate\Support\Facades\Log;
class PlatformEmailClient
{
private ?string $lastError = null;
public function lastError(): ?string
{
return $this->lastError;
}
private function base(): string
{
return rtrim((string) config('smtp.platform_api_url', 'https://ladill.com/api/smtp'), '/');
@@ -19,7 +26,11 @@ class PlatformEmailClient
public function send(string $ownerPublicId, string $to, string $subject, string $html, ?string $text = null): bool
{
$this->lastError = null;
if (! $this->isConfigured()) {
$this->lastError = 'Outbound email is not configured on this Events instance.';
return false;
}
@@ -36,12 +47,14 @@ class PlatformEmailClient
]));
if ($res->status() === 402) {
$this->lastError = (string) ($res->json('error') ?: 'Insufficient Bird email credits. Add funds in Billing and try again.');
Log::warning('Platform email send: insufficient balance', ['user' => $ownerPublicId]);
return false;
}
if ($res->failed()) {
$this->lastError = (string) ($res->json('error') ?: 'The email could not be sent. Please try again.');
Log::warning('Platform email send failed', ['status' => $res->status(), 'body' => $res->body()]);
return false;
@@ -49,6 +62,7 @@ class PlatformEmailClient
return (bool) ($res->json('success') ?? true);
} catch (\Throwable $e) {
$this->lastError = 'The email could not be sent. Please try again.';
Log::warning('Platform email send error', ['error' => $e->getMessage()]);
return false;
@@ -9,6 +9,11 @@ class EventEmailService
{
public function __construct(private readonly PlatformEmailClient $platform) {}
public function lastError(): ?string
{
return $this->platform->lastError();
}
public function sendProgrammeShare(
string $ownerPublicId,
string $to,
@@ -249,7 +249,8 @@ class EventSpeakerInviteService
if (! $sent) {
return [
'ok' => false,
'error' => 'The invitation email could not be sent. Check your Ladill wallet balance and try again.',
'error' => $this->email->lastError()
?: 'The invitation email could not be sent. Check your Bird email balance and verified sending domain, then try again.',
];
}