Email attachments (FileUpload) not working

I have the following simple email form:
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('subject')
->required()
->label('Email Subject'),
RichEditor::make('body')
->required()
->label('Email Body'),
FileUpload::make('attachments')
->multiple()
->label('Attachments')
->disk('public')
])
->statePath('data');
}

public function submit()
{
$subjectLine = $this->form->getState()['subject'];
$emailBody = $this->form->getState()['body'];
$attachments = $this->form->getState()['attachments'];

$emailAddresses = $this->records['emails'];

foreach ($emailAddresses as $emailAddress) {
Mail::to(
$emailAddress
)->send(
new BulkEventEmail(
$subjectLine,
$emailBody,
$attachments
)
);
}
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('subject')
->required()
->label('Email Subject'),
RichEditor::make('body')
->required()
->label('Email Body'),
FileUpload::make('attachments')
->multiple()
->label('Attachments')
->disk('public')
])
->statePath('data');
}

public function submit()
{
$subjectLine = $this->form->getState()['subject'];
$emailBody = $this->form->getState()['body'];
$attachments = $this->form->getState()['attachments'];

$emailAddresses = $this->records['emails'];

foreach ($emailAddresses as $emailAddress) {
Mail::to(
$emailAddress
)->send(
new BulkEventEmail(
$subjectLine,
$emailBody,
$attachments
)
);
}
}
It works just fine if I only send a subject line and body. If I add any attachments however, it gives me the attached error. I also logged it like so:
Log::info('Attachments:', ['attachments' => $attachments])
Log::info('Attachments:', ['attachments' => $attachments])
Here is the results of that:
[2024-09-21 01:10:23] production.INFO: Attachments: {["UaJx4a4GXjJdbU03KMFztS5EHyqQat-metacm91dGVzX291dHB1dC5jc3Y=-.csv"]}
[2024-09-21 01:10:23] production.INFO: Attachments: {["UaJx4a4GXjJdbU03KMFztS5EHyqQat-metacm91dGVzX291dHB1dC5jc3Y=-.csv"]}
Attached is the part of my code error message highlights. As this is a totally unhelpful error, also attached is the only suspicious vendor frame I saw. Looks like it wants the attachments to be sent through as a nested array... I tried manually building it like that, no luck. I'm out of characters, so I've also attached the attachments portion of my mailable. Any ideas how to do this properly?
No description
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server