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?
- Update Custom Field on Imported Post Creation
- Change title and meta description in included page (not template)
- spliting posts into two columns
- Page Reloads Before AJAX Request Finishes
- Link for Most Recent Post
- wp-load Without Loading the plugins
- Display WordPress Post Content in 3 Columns
- Target post_date_gmt if it’s empty or not set
- Remove page title in product page using a function
- woocommerce specific quantities for product
- Separate array output into a
- Why in this WordPress theme I can’t see the Main Menu?
- Restrict post to current user in postmeta
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- How can one safely add html code to a wordpress theme header file?
- Error `this set of changes has already been published`
- Where does php code to load data go?
- Adding product permalink on admin order page throwing error
- How to create dynamic templates?
- How to create an unordered list of images separate from the content
- How can I update a value of a field depending on outside source?
- Restricting access to a file for everyone except logged in users