Contact Form 7 allows users to upload their files via form, and then an email with attachments of the files is sent.
Rather than using form or form settings to attach the files, we can manually send the attachment of the files(filetypes:image/*|txt|application/pdf) in an email using the filter. We can use the contact-form-7 wpcf7 mail components hook to send the attachment manually.
The following example is for adding a hook callback and sending the attachment in an email. We can tweak the code to send attachments based on the requirement of the project.
add_filter( 'wpcf7_mail_components', function ($components){ $components['attachments'][] = get_template_directory().'/doc/sample.doc'; // PDF Path return $components; });
Views: 35