Help with sending emails with attached files #1292
-
Hello friends, I'm a little lost in the WinterCMS documentation, about how to attach files from a form on the Frontend by email. In this form, I can send several files (.pdf, .doc or .jpg). In the Plugin that I created on the Backend, I receive the form data as follows:
My Frontend form:
However, when I process the attachment of files to the form and click submit, nothing happens. I believe that some parameter is missing. Does anyone have an example of how to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@valentesolucoes try adding the |
Beta Was this translation helpful? Give feedback.
-
@valentesolucoes you might have to attach each individual files seperately.
Mail::send('frontend::mail.attachments', $params, function ($message) use ($params) {
$message->to('me@gmail.com', '');
foreach($params['files'] as $file) {
$message->attach($file, ['as' => $file->getClientOriginalName()]);
}
} |
Beta Was this translation helpful? Give feedback.
I have this code
I notice your name does not have the array notation []: https://wintercms.com/docs/v1.2/docs/database/attachments#:~:text=%3Cinput%20type%3D%27file%27%20name%3D%27files%5B%5D%27%20multiple%3E (i've had this issue in the past too)