Files
alrahma_sunday_school_api/app/Services/BroadcastEmail/BroadcastEmailSenderOptionsService.php
T
2026-06-08 23:30:22 -04:00

35 lines
887 B
PHP

<?php
namespace App\Services\BroadcastEmail;
class BroadcastEmailSenderOptionsService
{
public function listOptions(): array
{
$json = getenv('MAIL_SENDERS') ?: env('MAIL_SENDERS', '{}');
$arr = json_decode($json, true);
if (! is_array($arr) || empty($arr)) {
$smtpUser = getenv('SMTP_USER') ?: '';
$name = 'Al Rahma Sunday School';
return [[
'key' => 'general',
'label' => $name.($smtpUser ? " <{$smtpUser}>" : ''),
]];
}
$out = [];
foreach ($arr as $key => $info) {
$name = $info['name'] ?? 'Sender';
$email = $info['email'] ?? '';
$out[] = [
'key' => (string) $key,
'label' => trim($name.($email ? " <{$email}>" : '')),
];
}
return $out;
}
}