I encountered a problem when trying to send attachments with "Archive a copy of this message on this website" unchecked.
A few details about our system:
Temporary file path is set to /tmp
Default download method is private
Users with ability to send mass contact messages also have the "Send arbitrary files" permission associated to their role.
Despite having the above permission we were still encountering problems sending attachments. I have created the following patch against 7.x-1.0 that changes the _mass_contact_process_mime_mail_attachments method addition to the file array for files that are not stored for archival purposes. It removes the filepath and uri properties from the $files array entry in favor of a filecontent property that contains the contents of the file referenced.
I hope this fix helps out others and makes its way into 7.x-1.x-dev for an upcoming release. I'd really like to see this implemented in 1.1 as to not have to re-patch this file when the update is available.
Thanks a million!
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | fix-file-attachments-saved-unsaved-paths-2423647-5.patch | 1.24 KB | anybody |
| #1 | mass_contact-unable-to-send-attachment-when-archive-unchecked-2423647-1.patch | 726 bytes | dasginganinja |
Comments
Comment #1
dasginganinjaComment #2
dasginganinjaIf a patch needs to be rolled against 7.x-1.x let me know and I can provide it.
Comment #3
dasginganinjaComment #4
arkestra commentedThis patch works wonderfully. Could this be added to the dev branch, if not already there?
Thanks!
Comment #5
anybodyHere's the final patch that works for saved AND unsaved mass messages. Both have to be changed to fix this issue completely.
I tested it and I'm using the fix in production.
Please RTBC and create a new stable release. File uploads are currently NOT WORKING at all.
Comment #6
oadaeh commentedIn testing this, I was not able to reproduce the problem. I was able to send and save attachments in every configuration format I tried. Is there a specific configuration setting where this manifests?
The patches fundamentally change the way attachments are set up for use with Mime Mail. Did your testing include sending mail with Mime Mail?
Also, have you tried with Mass Contact 7.x-1.1, as that is the current version?
Comment #7
oadaeh commentedI marked #2733421: Attachment destroyed to 1kb file as a duplicate of this issue.
Comment #8
oadaeh commentedI marked #2727903: Format error with attachments as a duplicate of this issue.
Comment #9
oadaeh commentedI marked #2793893: Attachment files such a pdf are send but cannot be read by recipients. as a duplicate of this issue.
Comment #10
divcg commentedI have also just experienced this issue. I needed to use the patch that was provided here and it worked perfectly to solve the issue of 1k broken attachments that only contained the tmp file URL as content. I have the Mime Mail module enabled as required. I am currently running Drupal 7.43 (will be updating shortly). I had no special setups and just installed this module. Does not matter if I had create node checked or unchecked I still got 1k attachments
Comment #11
anybody@divcg: Thanks a lot for your feedback. Could you please tell us which patch (#) you used and which module versions (mimemail, mass contact) you are using? That way oadaeh may reproduce this. We should really fix this or find a solution.
Comment #12
oadaeh commented@Anybody, would you please try making a modification to your submitted patch and test it to see if things still work for you? The change is simply to leave the lines you removed in place and only add the one you added. If that change still works for you, I'll commit it. Thanks.
Also, which version of Mass Contact are you using?
Comment #13
anybodyYes, that works for me, thank you. Lets hope it works for all of us :)
Comment #14
anybodyComment #17
oadaeh commentedI committed the patch to the 7.x-1.x branch with a modification to avoid triplicate calls to drupal_realpath().
I'm going to leave this open for now, to see that it fixes the problem for everyone and doesn't haven any side effects.
Once I am confident all is okay, I'll close this and tag a new release.
Thanks everyone.
Comment #18
oadaeh commentedSince there has been no further discussion, I'm marking this fixed.
Comment #19
anybodyThank you , works perfectly.
Comment #21
rickj commentedI've just discovered that this patch as submitted doesn't work (first time I've actually needed to send an attachment).
The code in patch #5 works fine, but the committed version with the original lines in place doesn't. It creates what looks like the correct attachment, but the content is the URL of the file, not the file contents.
I'm using Mail System 7.x-2.35 and Mime Mail 7.x-1.1+11-dev. I'm guessing from the dates above that this was originally tested with Mime Mail 7.x-1.0. Have the Mime Mail updates affected the behaviour?