Files
ladill-events/app/Services/Events/EventEmailService.php
T
isaaccladandCursor 1db499ba2f
Deploy Ladill Events / deploy (push) Successful in 44s
Surface platform SMTP errors on speaker invitation failures.
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>
2026-07-03 16:23:09 +00:00

117 lines
3.2 KiB
PHP

<?php
namespace App\Services\Events;
use App\Services\Billing\PlatformEmailClient;
use Illuminate\Support\Facades\View;
class EventEmailService
{
public function __construct(private readonly PlatformEmailClient $platform) {}
public function lastError(): ?string
{
return $this->platform->lastError();
}
public function sendProgrammeShare(
string $ownerPublicId,
string $to,
string $eventName,
string $programmeUrl,
?string $attendeeName = null,
): bool {
return $this->send(
$ownerPublicId,
$to,
'Programme for '.$eventName,
'mail.notifications.event-programme',
compact('eventName', 'programmeUrl', 'attendeeName'),
);
}
public function sendJoinLink(
string $ownerPublicId,
string $to,
string $eventName,
string $joinUrl,
?string $attendeeName = null,
): bool {
return $this->send(
$ownerPublicId,
$to,
'Join '.$eventName,
'mail.notifications.event-join',
compact('eventName', 'joinUrl', 'attendeeName'),
);
}
public function sendJoinAndProgramme(
string $ownerPublicId,
string $to,
string $eventName,
string $joinUrl,
string $programmeUrl,
?string $attendeeName = null,
): bool {
return $this->send(
$ownerPublicId,
$to,
$eventName.' — programme & join link',
'mail.notifications.event-join-programme',
compact('eventName', 'joinUrl', 'programmeUrl', 'attendeeName'),
);
}
public function sendRegistrationConfirmation(
string $ownerPublicId,
string $to,
string $eventName,
string $badgeCode,
?string $joinUrl = null,
?string $attendeeName = null,
): bool {
return $this->send(
$ownerPublicId,
$to,
'Registration confirmed — '.$eventName,
'mail.notifications.event-registration-confirmed',
compact('eventName', 'badgeCode', 'joinUrl', 'attendeeName'),
);
}
public function sendSpeakerInvite(
string $ownerPublicId,
string $to,
string $eventName,
string $portalUrl,
?string $speakerName = null,
): bool {
return $this->send(
$ownerPublicId,
$to,
'Speaker invitation — '.$eventName,
'mail.notifications.event-speaker-invite',
[
'eventName' => $eventName,
'portalUrl' => $portalUrl,
'speakerName' => $speakerName,
],
);
}
/** @param array<string, mixed> $viewData */
private function send(string $ownerPublicId, string $to, string $subject, string $view, array $viewData): bool
{
$html = View::make($view, $viewData)->render();
return $this->platform->send(
$ownerPublicId,
$to,
$subject,
$html,
strip_tags(str_replace(['<br>', '<br/>', '<br />'], "\n", $html)),
);
}
}