Files
alrahma_sunday_school_api/app/Services/BroadcastEmail/BroadcastEmailComposerService.php
T
2026-06-09 01:25:14 -04:00

37 lines
954 B
PHP

<?php
namespace App\Services\BroadcastEmail;
use App\Support\MailHtml;
class BroadcastEmailComposerService
{
public function sanitizeHtml(string $html): string
{
$html = preg_replace('#<(script|iframe)[^>]*>.*?</\\1>#is', '', $html);
$html = preg_replace('/\\son\\w+="[^"]*"/i', '', $html);
$html = preg_replace("/\\son\\w+='[^']*'/i", '', $html);
return $html ?? '';
}
public function compose(
bool $wrapLayout,
string $subject,
string $body,
string $recipientName,
string $preheader = '',
string $ctaText = '',
string $ctaUrl = '',
bool $personalize = true
): string {
$content = $personalize ? str_replace('{{name}}', $recipientName, $body) : $body;
if (! $wrapLayout) {
return $content;
}
return MailHtml::broadcastCompose($subject, $content, $preheader, $ctaText, $ctaUrl);
}
}