I’ve found what’s been missing in the code. You have to add this also:
add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
function mycustom_wpcf7_mail_components( $components ) {
$components['attachments'][] = get_template_directory().'/pdf/test.pdf';
return $components;
}
Now everything is working fine and the file is attached to email without the need to add fields in the contact form.
Related Posts:
- How can I send an email using PHP?
- WordPress refuses to send mail, “…your host may have disabled the mail() function”
- How do I override the Message-ID header of wp_mail function?
- How to disable wordpress confirmation email for new users
- TCPDF get_post_meta outside the loop
- Best way to create a user programatically
- Should I use wp_mail or PHP’s mail? [duplicate]
- Mail not sent when I set HTML headers
- Get value of contact form 7 radio button [closed]
- Send PDF link in email based on radio button selection
- automatic PDF invoice with FPDF in PHP (creating Plugin)
- How to find the output of contact form 7 shortcode? [closed]
- Woocommerce HTML email option unavailable
- Contact Form 7 from adding paragraph and break tags to HTML emails [closed]
- Trigger Woocommerce New User Email
- Processing a subscription form with POST method?
- Different Webhost and using Google Mail server: Is there a better way than SMTP?
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- Set a condition based on WooCommerce checkout city field while placing order
- WooCommerce – Email admin with new user details
- How do you use WP slugs for PDF files / media?
- How to display posts by current user in a drop down
- How do you ensure that a user is recognised and available for use only when it is verified through a row in the database called ‘accountVerified’?
- PHP 8, AJAX mail form to function.php doesn’t work
- PDF file randomly breaks upon upload
- Capture User Email Address When Filling Out Form
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Send multiple attachments with wp_mail in PHP
- How to retrieve the sender email with wp_mail()?
- PhantomJS with wordpress
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Can I get an email notification when media is uploaded to the media library?
- Woocommerce Email attachments not working – file not being attached
- Download PDF after CF7 form submission
- Contact Form 7 – Replace database configured form template with a static file
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Get user custom field value on function.php
- Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts
- Pass return-path additional parameter in wp_mail
- difference between sanitize_email ,FILTER_VALIDATE_EMAIL and input email type in html5
- Using CFDB7 vs Custom MySQL Database [closed]
- Pass get data from anchor URL [closed]
- Use of antispambot with $curauth->email
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Contact form – problem with displaying message about sent mail
- Contact Form 7 WordPress, checking a few fields, if empty then invalid
- Add custom HTML data to Contact Form 7 mail?
- How to setup the Email piping in WordPress plugin?
- Is it secure to use SMTP password in .php file in WordPress website?
- Send an e-mail on address with the link with disliked post
- I want to fusion the product columns in email table order
- Woocommerce checkout page – custom field checkbox value into email
- Attach and retrive multiple pdf files to post or page
- How to use Contact Form 7 shortcode value in a page?
- Changing default WPMU emails to be send thorugh Campaign Monitor Transactional emails
- Send email to users when they get new followers
- How can disable wordpress emails notifications?
- Woocommerce custom field on emails outputs ‘Array’
- Using Custom Javascript and pHp to send email to myself when a user clicks on an input button but only works on Chrome, IE, and Micorosft Edge
- Wp_mail doesnt work
- Trying send mail from Theme page
- get_post_meta is always empty when I use wp_mail
- Cron job to call php to email last 24 hours posts
- How to check “From Email” via WordPress before an email is sent
- Search through documents folder
- How To: Simple domPDF Example
- Adding multiple emails to a
- Send foreach $_post method to contact form 7 [closed]
- Import and use a variable in additional settings of Contact Form 7 [closed]
- How can I prevent wordpress from sending emails
- Saving User Input to PHP Variable
- Submit cf7 form to cfdb as pdf/BLOB [closed]
- Contact form with dynamic dropdown and filter
- Dynamic Email Handler with ‘header (“Location: …’
- Customize the summary table of an order in the email
- How can I save a user’s Contact Form 7 inputs as separate columns in a custom WordPress table?
- Why does WordPress not send the user the email to add a password?
- Why is my custom email notification after purchase not sending?
- Send emails to individual subscribers when CPT post is deleted (trashed)
- Send summary email from a form with wp_mail
- WordPress admin area not sending mail (but works with WP Mail SMTP, Test Mail, and PHP mail() function)
- Limit Taxonomy Output in Conditional Statement
- Problem with AJAX in wordpress plugin
- WordPress archive page showing 404 Error [duplicate]
- wp_redirect only works on main site and not on other sites
- How to remove coupon dropdown feature
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Is it save to use eval for a jQuery callback method coming from the database?
- Division by zero error in image.php
- linking stylesheets and scripts with functions.php
- Jquery window.send_to_editor function
- PHP include statement not working?
- Code Executing Too Late?
- Double jQuery loaded
- PHP: Showing currency sign if input is a number
- Displaying text if post was within 5 hours
- New walker for walker_nav_menu to change inside container data
- load ajax using admin-ajax.php
- Create a WordPress shortcode using PHP [duplicate]
- Trying to prepend a Hashtag symbol to the_tags links [closed]