diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 59effb1deac..739223a5c66 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -440,9 +440,9 @@ class FormMail extends Form
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) {
- foreach ($this->param['fileinit'] as $file) {
- if (!empty($file)) {
- $this->add_attached_files($file, basename($file), dol_mimetype($file));
+ foreach ($this->param['fileinit'] as $path) {
+ if (!empty($path)) {
+ $this->add_attached_files($path);
}
}
}