Fix: E-mail attachment not sending
-
Hi guys
@mcdcba you might want to read the TL:DR since you had a similar issue and needed a fix.
Situation
We use a CF7-Form to take in applications for apprenticeships. We decided to use the dnd plugin because it’s easily understandable for kids/teens applying.I’ve noticed inconsistent behavior regarding e-mail attachments. Sometimes all the files arrived, then only 1 of 3 files would be attached and most of the time lately none would come through. We then have to write every applicant to please send us the missing files again, which first of all takes time and more importantly lets us appear as very unprofessional.
The form is configured to send us an e-mail with the files attached and also includes a list with the attached files in the e-mail.
I tried to recreate the error but it seemed impossible. What I didn’t consider was the time the applicants take to reread the form to check if they made a mistake somewhere.
I then went on and uploaded the files and then waited for approximately 5 minutes and then submitted the application. The e-mail I received didn’t have the attached files.
Explanation
I then looked into the code of both plugins to see why this could be happening. I discovered that the drag and drop plugin stores the files attached to the e-mail in the /wp-content/uploads/wpcf7_uploads directory but I couldn’t find any code responsible for deleting them afterwards. So I looked in to CF7 itself and found the function wpcf7_cleanup_upload_files which deletes files older than 60 seconds.So if you upload a file to your form and it then takes you longer than 60s to actually send it, the email you’ll be receiving won’t have an attachment because the file to be attached to the e-mail wasn’t on your server anymore. Fix is down below.
TL:DR
CF7 automatically deletes every file older than 60 seconds in the /wp-content/uploads/wpcf7_uploads directory.FIX:
To fix this until there is an official update just change to amount of seconds allowed for a file to remain in /wp-content/plugins/contact-form-7/modules/file.php on row 420. (wpcf7_cleanup_upload_files( $seconds = 60, $max = 100 ))
- The topic ‘Fix: E-mail attachment not sending’ is closed to new replies.