Problem/Motivation
It is currently not possible to configure which file elements should be attached to an email, while still keeping them available in the email body.
The email handler provides the option "Include files as attachments" (attachments). When enabled, all files of the file elements that are included in the email values are automatically attached to the email.
There is also a configuration option "Exclude file elements with attachments" (exclude_attachments), which allows hiding file elements from the email body while still attaching them.
Currently, when attachments are enabled, there is no way to:
- include a specific file element in the email values without attaching it
- attach only a subset of file elements while still showing all file elements in the email body
Example use case
A webform contains 3 file elements:
- a → should be shown + attached
- b → should be shown + attached
- c → should be shown but not attached
Steps to reproduce
- Create a webform with multiple file upload elements (
a,b,c) - Add and configure an email handler
- Enable "Include files as attachments"
- Ensure all file elements are included in the email values
- Submit the form to send the email
All files of the file elements (a, b,c) are attached to the email and available in the email body. It was not possible to configure that the files of element c should not be attached to the email.
Proposed resolution
Introduce a new configuration setting like included_attachment_elements, similar to excluded_elements, to explicitly define which file elements should be attached to the email.
The default behavior can remain unchanged (all file elements are attached), but the additional configuration allows to opt-out specific file elements when needed.
User interface changes
When "Include files as attachments" is enabled, display an additional configuration field allowing users to (un)select (opt-out) which file elements should be attached.
This can be implemented as a list of checkboxes containing all file elements, where:
- Checked = file element is attached
- Unchecked = file element is not attached
| Comment | File | Size | Author |
|---|---|---|---|
| webform-email-handler-configure-elements-to-attach.patch | 8.72 KB | arno_vgh |
Issue fork webform-3583485
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
liam morlandThanks for the patch. Tests are not passing. Our focus is currently on getting a 6.3.0 stable release so no new features will be included at this time.