7.9.4 Email Attachments Duplicated

When sending an email with attachments in SuiteCRM the attachment arrives duplicated.

Steps followed:

Click on contact record, click on email address, draft email address, attach file, click send.

Outcome

Email arrives with 2 files attached, not one.

I think this is a known issue

https://github.com/salesagility/SuiteCRM/issues/3818

Thanks
Not sure why it got labelled low priority, it’s a bit of a major when every email you send has duplicated attachments (Well that’s just my opinion).
Thanks for getting back to me.

This task was marked as low priority and then changed to Medium, but i think this is a very critical issue. How does the nature of this task make it a medium priority. I attach 4 quotes in email and the client receives 8. It is a Blocking issue which stops us to use emails module al together. If there is any fix available please share it.

Hi cherub-chum,

We tend to use the high priority label for issues that completely block basic functionality with no workaround. In this case as you are still able to send an email with an attachment, the medium priority label would more appropriate.

I need apply a dirty fix
// Quick fix
$_FILES[“email_attachment”][“name”] = array_unique($_FILES[“email_attachment”][“name”]);
$_FILES[“email_attachment”][“type”] = array_unique($_FILES[“email_attachment”][“type”]);
$_FILES[“email_attachment”][“tmp_name”] = array_unique($_FILES[“email_attachment”][“tmp_name”]);
$_FILES[“email_attachment”][“error”] = array_unique($_FILES[“email_attachment”][“error”]);
$_FILES[“email_attachment”][“error”] = array_unique($_FILES[“email_attachment”][“error”]);
for ($i = 0; $i < $max_files_upload; $i++) {

@binhcools, can you please post that inside the forum’s “code” tags? Otherwise some parts of the code disappear.

I need apply a dirty fix

// Quick fix
$_FILES["email_attachment"]["name"] = array_unique($_FILES["email_attachment"]["name"]);
$_FILES["email_attachment"]["type"] = array_unique($_FILES["email_attachment"]["type"]);
$_FILES["email_attachment"]["tmp_name"] = array_unique($_FILES["email_attachment"]["tmp_name"]);
$_FILES["email_attachment"]["error"] = array_unique($_FILES["email_attachment"]["error"]);
$_FILES["email_attachment"]["error"] = array_unique($_FILES["email_attachment"]["error"]);
for ($i = 0; $i < $max_files_upload; $i++) {

I thought there was more code after the “for”…

You don’t say where you apply this fix? Which file, and around which line?

The file would be modules/Emails/Email.php and there are two functions using this.

handleAttachments and handleMultipleFileAttachments

Lines for the above fix are before 2182 and 2379.

1 Like

Can we make a proper fix from this? Better than removing the duplicates, it would be nice to prevent them from duplicatiing in the first place…

Sorry, the code above for is dirty fix that I applied to my own project the make attachment not duplicated. Somehow the $_FILES[“email_attachment”] is duplicated. I think this problems is caused by editor or javscript at client ( the EmailsComposeView.js ) But I can’t fix it thoroughly, so I apply that quick fix.
The code I applied is placed in Emails.php line 2395 above
for ($i = 0; $i < $max_files_upload; $i++) {

Regards,

One thing that does look suspicious and has been added in 7.9.x version files is the Code Segment at 225 line number starting with

 if(!mozaik.uploadPathField) 

in the file

modules/Emails/javascript/Email.js

I placed a “debugger” above that line, but the code not run to there, I thought the Email.js is not have any relation here, we just have EmailsComposeView.js working here,
What do you think ?

Check out the article here on Github for a possible solution

https://github.com/salesagility/SuiteCRM/issues/4645

https://github.com/salesagility/SuiteCRM/issues/3818

This has been resolved in version 7.9.9

This issue is still happening in Version 7.11.15