Files
ladill-events/app/Services/Events/EventEmailService.php
T
isaaccladandCursor 1746874aaa
Deploy Ladill Events / deploy (push) Successful in 49s
Use noreply@ladill.com for Events mail like other Ladill apps.
Stop overriding the From display name with the event title; rely on MAIL_FROM_ADDRESS and MAIL_FROM_NAME only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-03 17:20:45 +00:00

146 lines
3.9 KiB
PHP

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