Files
2026-06-11 11:46:12 -04:00

39 lines
1006 B
PHP

<?php
namespace App\Services\Email;
class EmailSenderOptionsService
{
public function listSenders(): array
{
$json = 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',
'name' => $name,
'email' => $smtpUser,
'label' => trim($name.($smtpUser ? " <{$smtpUser}>" : '')),
]];
}
$out = [];
foreach ($arr as $key => $info) {
$name = $info['name'] ?? 'Sender';
$email = $info['email'] ?? '';
$out[] = [
'key' => (string) $key,
'name' => (string) $name,
'email' => (string) $email,
'label' => trim($name.($email ? " <{$email}>" : '')),
];
}
return $out;
}
}