We’ve run into the similar issue on our site, since a recent update the attachments are no longer being sent. I’ve been able to identify the problem and including the solution below.
Problem
Our site is hosted on Pantheon. So the WordPress code lives in /code
folder and all files live in /files
folder. This was not the problem before.
Per documented instructions the upload path can be customized to any location. In case of server such as Pantheon the standard path of files /wp-content/uploads
is just an alias to the /files
folder.
The code in the Contact Form 7 plugin in file mail.php does the explicit check that the attachment is in the WP_CONTENT directory if ( ! wpcf7_is_file_path_in_content_dir( $path ) ) {
. In our case this will always be false so the attachment is never attached although it does exist in a directory that the plugin can freely read.
This is a wrong assumption for the code to make. It may work with traditional servers. But as hosts try to optimize content delivery by segmenting out files, this will fail. Pantheon is being one such host.
Replication Steps
* Create a WordPress installation
* Create a file storage folder outside of the WordPress code folder
* Create a symbolic link from /wp-content/uploads
to lead to a new folder created in a previous step
* Configure a form with file attachment
* Submit the form, see the email with out an attachment
Proposed Solution
Replace the statement if ( ! wpcf7_is_file_path_in_content_dir( $path ) ) {
with a check that the plugin user has access to the directory and permissions to read the attached file. This will ensure that only authorized files are attached and will not fail when the files live outside of the WordPress structure.
If that doesn’t seem to be the best solution, then another option is to verify that the file lives in the directory specified by WPCF7_UPLOADS_TMP_DIR
which may be an absolute server path and also live outside of WordPress root directory.
@takayukister Please let me know if this is sufficient information to create a solution. Don’t hesitate to reach out if you need any additional
-
This reply was modified 3 years, 5 months ago by makbeta.
-
This reply was modified 3 years, 5 months ago by makbeta.