Syntax for adding attachment to mail

I use the plugin Uniform to send emails with a html template. That works :slight_smile:

I want to add an .ics (calendar) file attachment to the email. This file should be filled with some fields from the form. I want to use the ā€˜content representationā€™ functionality. That - I could not get to work :frowning:

What I have
I have made an agenda.ics.php file in the templates folder. I made a page in the content/ folder that uses the agenda template. I can open the .ics file in my browser with url: kirby.test/calendar_event.ics - it will download the (static) ICS file.
But I havenā€™t succeeded in attaching any file to an email.

I have some questions

  1. What is the syntax for the ā€˜attachmentsā€™ => ā€œā€ when I want to add a dynamic file? See code snippet below.
  2. Is ā€˜content representationā€™ the best way to make a dynamic file available that can be attached?
  3. How can I make the attachment file dynamic, so how can I add 3 fields from the form into the .ics file?

I have read many forum posts about attachments, and tried a lot of probable syntaxes, but I have not found an answer yet.

 if ($kirby->request()->is('POST')) {
    $form->emailAction([
        'to' => 'somebody@planet.nl',
        'from' => 'info@example2.com',
        'template' => 'success',
        'attachments' => $_FILES['http://kirby.test/calendar_event.ics'],
    ])->done();
  }

Thanks!
RenƩ

I think I took the wrong path. I have found a php gist to do it.
Iā€™ll try this and if itā€™s working (or not) Iā€™ll report back.

Thx

1 Like