Fixed attachemnts not working on production
This commit is contained in:
parent
3b1a24287a
commit
f54f198879
|
|
@ -186,9 +186,35 @@ public function sendFromLog(EmailLog $log): array
|
|||
}
|
||||
$name = $att['name'] ?? basename($path);
|
||||
$mime = $att['mime'] ?? 'application/octet-stream';
|
||||
$full = \Storage::disk($disk)->path($path);
|
||||
if (is_file($full)) {
|
||||
$email->attachFromPath($full, $name, $mime);
|
||||
|
||||
$attached = false;
|
||||
$storage = \Storage::disk($disk);
|
||||
// Prefer local path when available (local driver)
|
||||
try {
|
||||
if (method_exists($storage, 'path')) {
|
||||
$full = $storage->path($path);
|
||||
if (is_string($full) && is_file($full)) {
|
||||
$email->attachFromPath($full, $name, $mime);
|
||||
$attached = true;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// fall through to bytes
|
||||
}
|
||||
|
||||
if (! $attached) {
|
||||
// Fallback for non-local disks (e.g., S3): read bytes and attach directly
|
||||
try {
|
||||
if ($storage->exists($path)) {
|
||||
$bytes = $storage->get($path);
|
||||
if (! is_null($bytes) && $bytes !== false) {
|
||||
$email->attach($bytes, $name, $mime);
|
||||
$attached = true;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// ignore, continue to next attachment
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// ignore individual attachment failures; continue sending
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user