Problem/Motivation

Allows for adding attachments to the outgoing email messages.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

jhedstrom created an issue. See original summary.

embeau’s picture

We use this module on a client's site and they wanted to add the ability to attach files to their emails. The features on the main page for this project say: The message may include one or more binary file attachments. (The Drupal 7 version requires the Mime Mail module.)
This lead me to believe that I could easily add attachments in Drupal 8. I discovered, however, that this functionality was not even built for Drupal 8. Only the permission is there, which does nothing. This is extremely deceiving and this functionality should not be listed on the main page as a D8 feature when it is not there.

I found this issue https://www.drupal.org/project/mass_contact/issues/3018920 where someone started a patch for this to work. I built off of that patch and added the desired functionality (see comment #5 on that issue page).

I updated the Email body settings page to include an Attachments area. Here, the user is able to input via the UI the upload destination (public or private), the file directory, the allowed file extensions, and the max upload size.

I updated the mass contact form itself to display the attachments field when the user has the permission. I allow for multiple file attachments and validate the size and extension. Upon submitting the form, I loop through the array of attached files to get the necessary data for each to send along with the rest of the message.

I left some todos in EmailBodyForm.php regarding validation of the user input for the various settings. If anyone has some guidance on how to go about doing this, please let me know.

gaurav.kapoor’s picture

Status: Active » Closed (duplicate)