Way to add attachment to contactform

I use this: https://gist.github.com/bastianallgeier/c396df7923848912393d for building a contactform.
Is it possible to add files to the generated mail?

I found no documentation on the appropriate method: kirby Toolkit: https://getkirby.com/docs/toolkit/api#email

Because the toolkit email class is โ€œjustโ€ a wrapper for the PHP mail function (and other email providers), you should be able to send attachments the same way as using the mail function directly. (Just google PHP mail attachment)

But as I took a look at the source code of the toolkit email class (https://github.com/getkirby/toolkit/blob/master/lib/email.php), there seems to be no way to add custom headers. This would be necessary to set the correct Content-Type and mail boundary.

So I think, you must write your own wrapper for the plain php mail function.

Have you seen this post? Maybe it helps.

I decided to use the I uniform plugin from @mzur. I set-up everything and asked myself if there is a working example uniform + usage of attachments. I saw the link from @texnixe. This one is based on uniform but extends it with PHPMailer. Is that really needed?

You donโ€™t have to use something like PHPMailer but it is much easier (and less error-prone) than implementing everything by yourself. You are not limited to PHPMailer: there are alternatives like Swiftmailer, too. But if you absolutely want to do it yourself, there are examples in the Stack Overflow answers I linked above.

Yes. Thanks. Do you have a complete, working example based on uniform and PHPMailer including the support for attachments?

No, sorry, youโ€™ll have to work that out using the thread mentioned before. Another example for an upload action is here.