Forms - sending file as email attachment not working

Hello, i updated grav with all plugins to latest version and now, sending uploaded file from from as email attachement is not working, i receive email without any attachments. This is my page with form:

title: Form page
form:
    name: email-form
    fields:
        - name: message
          label: 'write message
          placeholder: 'your message...'
          type: textarea
          validate:
            required: true
        
        - name: email
          label: 'e-mail'
          placeholder: 'e-mail address'
          autocomplete: 'off'
          type: email
          validate:
            required: true 
        
        - name: attachfile
          label: 'Attach file'
          type: file
          multiple: false
          avoid_overwriting: true

    buttons:
        - type: submit
          value: 'send'
        - type: reset
          value: 'resettt'
    
    process:
        - email:
          from: '{{ config.plugins.email.from }}'
          to: ['{{ form.value.email }}']
          subject: 'Sample mail'
          body: '{% include ''forms/data.html.twig'' %}'
          attachments: [attachfile]
        
        - message: 'Message was sent'

I am using antimatter theme, but the theme is not updated for support with forms 2.0 so i added {% include "forms/fields/formname/formname.html.twig" %} like it is in plugin’s template. Can you help me? Thanks

Antimatter has no issues with the new form update.

Pretty sure I fixed attachments in the last email plugin release: https://github.com/getgrav/grav-plugin-email/commit/881d7e371adcfb6dd526069685f2d5fb91aa014c are you using that?

I am running email v2.5.0, form v2.0.3 and antimatter v2.0.0. When i submit the form, i get this error:

TypeError
Argument 1 passed to Grav\Plugin\EmailPlugin::buildMessage() must be of the type array, null given, called in \user\plugins\email\email.php on line 74

Could be an indentation problem in the YAML form definition. The form parameters under email: cannot be found.

you were right, this fixed sending form :slight_smile: but attachments are still not working, i recieve email with text input values, but no attachement. I also tried uploading .exe file and it sent email, but i have configured plugin to accept only image types.

Can you please open an issue on the email plugin repository? Better place to track bugs

finally found it, issue was on my side and it is working now. But i prefer old upload without ajax, it is possible to use classic input field without javascript? thanks

It’s really not possible. It did ‘work’ before in basic usage, but fell apart quickly when used in complex scenarios like in list items. Without Ajax, the file upload happens when the form is submitted, and any errors etc (especially nested in other fields) are very hard to handle cleanly when repopulating the form for example. it’s just too messy and required so many workarounds and cludges we decided to rewrite that field entirely with a much cleaner and simpler ajax solution.