dpl/app/Services/MailFlow/Branding.php

23 lines
739 B
PHP

<?php
namespace App\Services\MailFlow;
class Branding
{
public static function values(): array
{
return ['site_url' => admin_setting('app_url', config('app.url')),
'logo_src' => self::attachments() ? 'cid:site-logo@dpl' : null];
}
public static function attachments(): array
{
$path = config('mailflow.logo_path');
if (!$path || !is_file($path) || filesize($path) > 512 * 1024) { return []; }
$bytes = file_get_contents($path);
if (!str_starts_with($bytes, "\x89PNG\r\n\x1a\n")) { return []; }
return [['filename' => 'site-logo.png', 'content' => base64_encode($bytes),
'content_type' => 'image/png', 'content_id' => 'site-logo@dpl']];
}
}