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')) {
        'to' => '',
        'from' => '',
        'template' => 'success',
        'attachments' => $_FILES['http://kirby.test/calendar_event.ics'],


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.


1 Like